Skip to content
Snippets Groups Projects
constants.py 6.87 KiB
#!/usr/bin/env python
# encoding: utf-8
"""
Module to store all constants.  Any constant needed in more than one
component, or potentially more than one part should be defined here.

Rules/Preferences:
    - All values lowercase
    - strings
    - user-legible (assume that they may be printed in log messages)
    - use == for comparison (not 'is' or 'not' or other)

:author:       Eva Schiffer (evas)
:contact:      eva.schiffer@ssec.wisc.edu
:organization: Space Science and Engineering Center (SSEC)
:copyright:    Copyright (c) 2014 University of Wisconsin SSEC. All rights reserved.
:date:         Jan 2014
:license:      GNU GPLv3

Copyright (C) 2014 - 2015 Space Science and Engineering Center (SSEC),
 University of Wisconsin-Madison.
"""
__docformat__ = "restructuredtext en"

import numpy

# some constants for time conversion
SECONDS_PER_HOUR          = 3600.0
DEGREES_LON_PER_HOUR      = 15.0
HOURS_PER_DEGREE_LON      = 24.0 / 360.0
HOURS_PER_DAY             = 24.0

# the line between day and night for our day/night masks (in solar zenith angle degrees)
DAY_NIGHT_LINE_DEGREES = 85.0

# these are constants for separating the cloud top pressure in to low/mid/high
#       high pressure is < 440
#       low  pressure is >= 680
#       mid pressure is everything in between
HIGH_CLOUD_TOP_PRESSURE_CONST = 440
LOW_CLOUD_TOP_PRESSURE_CONST  = 680

# constants for separating the cloud effective emissivity into thin/thick/opaque
#       thin is < 0.5
#       opaque is >= 0.95
#       thick is everything in between
THIN_CLOUDS_CUTOFF_CONST   = 0.5
OPAQUE_CLOUDS_CUTOFF_CONST = 0.95

# this is the default data type to output our data, can be overridden for specific variables in their guidebooks
DEFAULT_DATA_TYPE = numpy.float32

# constants for the satellite names
SAT_NOAA_14               = 'noaa-14'
SAT_NOAA_15               = 'noaa-15'
SAT_NOAA_16               = 'noaa-16'
SAT_NOAA_17               = 'noaa-17'
SAT_NOAA_18               = 'noaa-18'
SAT_NOAA_19               = 'noaa-19'
SAT_METOP_A               = 'metop-a'
SAT_METOP_B               = 'metop-b'
SAT_AQUA                  = "aqua"
SAT_TERRA                 = "terra"
SAT_SNPP                  = "snpp"
ALL_SATS                  = {SAT_NOAA_14,
                             SAT_NOAA_15,
                             SAT_NOAA_16,
                             SAT_NOAA_17,
                             SAT_NOAA_18,
                             SAT_NOAA_19,
                             SAT_METOP_A,
                             SAT_METOP_B,
                             SAT_AQUA,
                             SAT_TERRA}

# constants for the instrument types
INST_AVHRR                = 'avhrr'
INST_HIRS                 = 'hirs'
INST_MODIS                = "modis"
INST_VIIRS                = "viirs"

# keys for organizing data
LON_KEY                   = "longitude"
LAT_KEY                   = "latitude"
LON_INDEX_KEY             = "longitude-index"
LAT_INDEX_KEY             = "latitude-index"
SCAN_LINE_TIME_KEY        = "scanline-time"
SENSOR_ZENITH_ANGLE_KEY   = "sensor-zenith-angle"
DAY_MASK_KEY              = "day-mask"
NIGHT_MASK_KEY            = "night-mask"
SET_MASK_KEY              = "masks"
TIME_MASKS_KEY            = "time-of-day-masks"
PRESS_MASKS_KEY           = "high-mid-low-pressure-masks"
THICK_MASKS_KEY           = "thin-thick-opaque-masks"
# for keeping track of data sets for time gridding
SPACE_GRID_KEY            = "space gridded data"
BLANK_STEM_KEY            = "stem"

# keys for organizing data during space gridding
DENSITY_KEY               = "density"
NOBS_KEY                  = "nobs"
TIMES_KEY                 = "times"
ANGLES_KEY                = "angles"
SG_DATA_KEY               = "space-gridded-data"

# these are categories of separated data used in the system (several may stack)
TEMP_SUFFIX_KEY           = "temp"
DAILY_SPACE_SUFFIX_KEY    = "daily-space"
DAILY_TIME_SUFFIX_KEY     = "daily-time"
MULTI_TIME_SUFFIX_KEY     = "multiday-time"
NOBS_LUT_SUFFIX           = "lut-nobs" # number of observations look up table files
# these represent the categories data may be separated into for space or time gridding
# Note: because of how these are handled in the organizational code, these keys must be unique across all mask sets
HIGH_MODIFIER             = "high-press"      # high/mid/low are intended to be used for cloud top pressure categories
MID_MODIFIER              = "mid-press"
LOW_MODIFIER              = "low-press"
PRESS_SETS                = {HIGH_MODIFIER, MID_MODIFIER, LOW_MODIFIER}
THIN_MODIFIER             = "thin-emiss"      # thin/thick/opaque are intended for use with cloud effective emissivity
THICK_MODIFIER            = "thick-emiss"
OPAQUE_MODIFIER           = "opaque-emiss"
THICKNESS_SETS            = {THIN_MODIFIER, THICK_MODIFIER, OPAQUE_MODIFIER}
DAY_SET_KEY               = "day-time"        # day/night/morning/afternoon/evening/all are intended to separate data from different times of day
NIGHT_SET_KEY             = "night-time"
ALL_SET_KEY               = "all-time"
MORNING_SET_KEY           = "morning-time"
AFTERNOON_SET_KEY         = "afternoon-time"
EVENING_SET_KEY           = "evening-time"
ALL_TIMES_KEY             = "all-time"
TIME_SETS                 = {#DAY_SET_KEY, # not currently in use
                             NIGHT_SET_KEY,
                             #ALL_SET_KEY, # not currently in use
                             MORNING_SET_KEY,
                             AFTERNOON_SET_KEY,
                             EVENING_SET_KEY}
NO_CATEGORIES             = ""
# this will need to be upkept if more categories are added
ALL_CATEGORY_SETS         = {
                                PRESS_MASKS_KEY: PRESS_SETS,
                                THICK_MASKS_KEY: THICKNESS_SETS,
                                TIME_MASKS_KEY: TIME_SETS,
                                NO_CATEGORIES: {NO_CATEGORIES,},
                            }

# these represent additional data sub-types in both temporary and final files
DENSITY_SUFFIX            = "density"
NOBS_SUFFIX               = "num-observations" # number of observations
NUM_MES_SUFFIX            = "num-measurements" # number of measurements
MEAN_SUFFIX               = "mean"
STD_SUFFIX                = "std"
CLOUD_FRACTION_SUFFIX     = "cloud-fraction" # the cloud fraction
UNCERTAINTY_SUFFIX        = "uncertainty"

# some constants to describe file types
DAILY_SPACE_TYPE          = "daily-space-gridded"
DAILY_TIME_TYPE           = "daily-time-gridded"
MULTIDAY_TIME_TYPE        = "multiday-time-gridded"
NOBS_LUT_TYPE             = "nobs-look-up-table"
ALL_STG_FILE_TYPES        = {DAILY_SPACE_TYPE, DAILY_TIME_TYPE, MULTIDAY_TIME_TYPE, NOBS_LUT_TYPE}

# constants about our output file format
NETCDF_SUFFIX             = "nc"

# the next three are for classifying file sets
TEMP_FILE_TYPE            = "temp-file"
FINAL_OUT_FILE_TYPE       = "final-output-file"
ALL_FILES_TYPE            = "all-files"

# for use in the plotting tool
PLOT_SUFFIX               = "plot_stg_data"