Permalink
Browse files

Merge branch 'viirs_crefl'

Added all CREFL features. Updated crefl frontend to use the updated
VIIRS frontend boundary function (fill value).

Conflicts:
	py/polar2grid_viirs/polar2grid/viirs/viirs_guidebook.py
  • Loading branch information...
2 parents 5bc4b80 + 14d8ba6 commit 152364703efb54d6a2c1d6c29ee078c3aadc9b42 @davidh-ssec committed Apr 30, 2013
View
@@ -34,14 +34,15 @@ DIST_DIR ?= ./dist
CORE_PKG_DIR = polar2grid_core
VIIRS_PKG_DIR = polar2grid_viirs
MODIS_PKG_DIR = polar2grid_modis
+CREFL_PKG_DIR = polar2grid_crefl
MAIN_PKG_DIR = polar2grid
# Make sure target names are just the dir name with a suffix
# See targets for substitution
-ALL_PKG_DIRS = $(CORE_PKG_DIR) $(VIIRS_PKG_DIR) $(MODIS_PKG_DIR) $(MAIN_PKG_DIR)
+ALL_PKG_DIRS = $(CORE_PKG_DIR) $(VIIRS_PKG_DIR) $(MODIS_PKG_DIR) $(CREFL_PKG_DIR) $(MAIN_PKG_DIR)
ALL_PKG_SDIST = $(ALL_PKG_DIRS:=_sdist)
#ALL_PKG_SDIST = polar2grid_core_sdist polar2grid_viirs_sdist polar2grid_sdist
-ALL_PKG_DEV = polar2grid_core_dev polar2grid_viirs_dev polar2grid_modis_dev polar2grid_dev
+ALL_PKG_DEV = polar2grid_core_dev polar2grid_viirs_dev polar2grid_modis_dev polar2grid_crefl_dev polar2grid_dev
#DOC_DIR = /home/davidh/test_doc
DOC_DIR = /var/apache/www/htdocs/software/polar2grid

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -12,11 +12,13 @@ australia2, gpd, australia2.gpd, 105.000, 5.000, 175.000,
# PROJ.4 Grids
# proj4 grids may have None for sizes, origins, or pixel sizes to be considered 'dynamic'
# pixel size or grid size must be specified
-# grid_name, proj4, proj4_str, width, height, pixel_size_x, pixel_size_y, origin_x, origin_y
-p4_211e, proj4, +proj=lcc +datum=NAD83 +ellps=GRS80 +lat_1=25 +lon_0=-95 +no_defs, 5120, 5120, 1015.9, -1015.9, -1956254.806724622, 4364276.201489102
-lcc_fit, proj4, +proj=lcc +datum=WGS84 +ellps=WGS84 +lat_0=25 +lon_0=-95, None, None, 1000, -1000, None, None
-lcc_fit_hr, proj4, +proj=lcc +datum=WGS84 +ellps=WGS84 +lat_0=25 +lon_0=-95, None, None, 400, -400, None, None
-wgs84_fit, proj4, +proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs, None, None, 0.0001, -0.0001, None, None
-polar_canada, proj4, +proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=90 +lat_ts=45.0 +lon_0=-150, None, None, 1000, -1000, None, None
-polar_north_pacific, proj4, +proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=90 +lat_ts=45.0 +lon_0=-170, None, None, 400, -400, None, None
-polar_south_pacific, proj4, +proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=-90 +lat_ts=-45.0 +lon_0=-170, None, None, 400, -400, None, None
+# grid_name, proj4, proj4_str, width, height, pixel_size_x, pixel_size_y, origin_x, origin_y
+p4_211e, proj4, +proj=lcc +datum=NAD83 +ellps=GRS80 +lat_0=25 +lat_1=25 +lon_0=-95 +units=m +no_defs, 5120, 5120, 1015.9, -1015.9, -1956254.806724622, 4364276.201489102
+p4_211e_hi, proj4, +proj=lcc +datum=NAD83 +ellps=GRS80 +lat_0=25 +lat_1=25 +lon_0=-95 +units=m +no_defs, 10000, 10000, 500, -500, -1956254.806724622, 4364276.201489102
+lcc_fit, proj4, +proj=lcc +datum=WGS84 +ellps=WGS84 +lat_0=25 +lat_1=25 +lon_0=-95 +units=m +no_defs, None, None, 1000, -1000, None, None
+lcc_fit_hr, proj4, +proj=lcc +datum=WGS84 +ellps=WGS84 +lat_0=25 +lat_1=25 +lon_0=-95 +units=m +no_defs, None, None, 400, -400, None, None
+wgs84_fit, proj4, +proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs, None, None, 0.0001, -0.0001, None, None
+eqc_fit, proj4, +proj=eqc +datum=WGS84 +ellps=WGS84 +lat_ts=0 +lon_0=-100 +units=m +no_defs, None, None, 250, -250, None, None
+polar_canada, proj4, +proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=90 +lat_ts=45.0 +lon_0=-150 +units=m, None, None, 1000, -1000, None, None
+polar_north_pacific, proj4, +proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=90 +lat_ts=45.0 +lon_0=-170 +units=m, None, None, 400, -400, None, None
+polar_south_pacific, proj4, +proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=-90 +lat_ts=-45.0 +lon_0=-170 +units=m, None, None, 400, -400, None, None
@@ -171,7 +171,7 @@ def ll2cr(lon_arr, lat_arr, proj4_str,
log.debug("Data west longitude: %f" % swath_lon_west)
swath_lon_east = lon_arr[ good_mask & (lon_arr > 0) ].min()
log.debug("Data east longitude: %f" % swath_lon_east)
- stadles_180 = True
+ stradles_180 = True
### Find out if we stradle the anti-meridian of the projection ###
# Get the projections origin in lon/lat space
@@ -196,28 +196,30 @@ def ll2cr(lon_arr, lat_arr, proj4_str,
data_grid_west += proj_circum if data_grid_west < 0 else 0
data_grid_east += proj_circum if data_grid_east < 0 else 0
- # see if the grids bounds stadle the anti-meridian
+ # see if the grids bounds stradle the anti-meridian
stradles_anti = False
if (data_grid_west < proj_anti_x) and (data_grid_east > proj_anti_x):
log.debug("Data crosses the projections anti-meridian")
stradles_anti = True
- normal_lon_east = swath_lon_east if swath_lon_east > swath_lon_west else swath_lon_east + 360
- lon_range = numpy.linspace(swath_lon_west, normal_lon_east, 15)
- lat_range = numpy.linspace(swath_lat_north, swath_lat_south, 15)
-
- ### Create a matrix of projection points to find the bounding box of the grid ###
- # Test the left, right, ul2br diagonal, ur2bl diagonal, top, bottom
- # If we are over the north pole then handle strong possibility of data in all longitudes
- if swath_lat_north >= 89.5: bottom_lon_range = numpy.linspace(-180, 180, 15)
- else: bottom_lon_range = lon_range
- # If we are over the north pole then handle strong possibility of data in all longitudes
- if swath_lat_south <= -89.5: top_lon_range = numpy.linspace(-180, 180, 15)
- else: top_lon_range = lon_range
-
- lon_test = numpy.array([ [swath_lon_west]*15, [swath_lon_east]*15, lon_range, lon_range, top_lon_range, bottom_lon_range ])
- lat_test = numpy.array([ lat_range, lat_range, lat_range, lat_range[::-1], [swath_lat_north]*15, [swath_lat_south]*15 ])
- x_test,y_test = _transform_array(tformer, lon_test, lat_test, proj_circum, stradles_anti=stradles_anti)
+ # If we are doing anything dynamic, then we need to get the bounding box of the data in *grid* space
+ if grid_origin_x is None or grid_width is None or pixel_size_x is None:
+ normal_lon_east = swath_lon_east if swath_lon_east > swath_lon_west else swath_lon_east + 360
+ lon_range = numpy.linspace(swath_lon_west, normal_lon_east, 15)
+ lat_range = numpy.linspace(swath_lat_north, swath_lat_south, 15)
+
+ ### Create a matrix of projection points to find the bounding box of the grid ###
+ # Test the left, right, ul2br diagonal, ur2bl diagonal, top, bottom
+ # If we are over the north pole then handle strong possibility of data in all longitudes
+ if swath_lat_north >= 89.5: bottom_lon_range = numpy.linspace(-180, 180, 15)
+ else: bottom_lon_range = lon_range
+ # If we are over the north pole then handle strong possibility of data in all longitudes
+ if swath_lat_south <= -89.5: top_lon_range = numpy.linspace(-180, 180, 15)
+ else: top_lon_range = lon_range
+
+ lon_test = numpy.array([ [swath_lon_west]*15, [swath_lon_east]*15, lon_range, lon_range, top_lon_range, bottom_lon_range ])
+ lat_test = numpy.array([ lat_range, lat_range, lat_range, lat_range[::-1], [swath_lat_north]*15, [swath_lat_south]*15 ])
+ x_test,y_test = _transform_array(tformer, lon_test, lat_test, proj_circum, stradles_anti=stradles_anti)
# Calculate the best corners of the data
if grid_width is None or pixel_size_x is None:
@@ -90,6 +90,8 @@
BKIND_ICON = "ice_concentration"
BKIND_NDVI = "ndvi"
BKIND_TPW = "total_precipitable_water"
+BKIND_CREFL = "crefl"
+BKIND_TCOLOR_CREFL = "true_color_crefl"
# Band Identifier
BID_01 = "01"
@@ -127,6 +129,8 @@
DKIND_DISTANCE = "distance" # this is meant to be a distance in the sense of mm, cm, meters, km, or miles
DKIND_PERCENT = "percent"
DKIND_C_INDEX = "contiguous_index" # this represents some abstract ranging index with meaningfully contiguous values (not discrete categories)
+DKIND_CREFL = "corrected_reflectance"
+DKIND_TCOLOR_CREFL = "true_color_crefl"
SET_DKINDS = set([
DKIND_RADIANCE,
@@ -137,7 +141,9 @@
DKIND_ANGLE,
DKIND_DISTANCE,
DKIND_PERCENT,
- DKIND_C_INDEX
+ DKIND_C_INDEX,
+ DKIND_CREFL,
+ DKIND_TCOLOR_CREFL
])
# Data types (int,float,#bits,etc.)
@@ -156,7 +162,8 @@
MBAND_NAV_UID = "m_nav" # the M band navigation group
IBAND_NAV_UID = "i_nav" # the I band navigation group
DNB_NAV_UID = "dnb_nav" # the Day/Night band navigation group
-GEO_NAV_UID = "geo_nav" # the geo navigation group
+GEO_NAV_UID = "geo_1000m_nav"# the geo navigation group
+GEO_500M_NAV_UID = "geo_500m_nav" # the geo navigation group
GEO_250M_NAV_UID = "geo_250m_nav" # the 250m navigation group
MOD06_NAV_UID = "mod06_nav" # the mod06 navigation group
MOD07_NAV_UID = "mod07_nav" # the mod07 navigation group
@@ -116,6 +116,38 @@ def sqrt_scale(img, inner_mult, outer_mult, fill_in=DEFAULT_FILL_IN, fill_out=DE
img[mask] = fill_out
return img
+pw_255_lookup_table = numpy.array([ 0, 3, 7, 10, 14, 18, 21, 25, 28, 32, 36, 39, 43,
+ 46, 50, 54, 57, 61, 64, 68, 72, 75, 79, 82, 86, 90,
+ 91, 93, 95, 96, 98, 100, 101, 103, 105, 106, 108, 110, 111,
+ 113, 115, 116, 118, 120, 121, 123, 125, 126, 128, 130, 131, 133,
+ 135, 136, 138, 140, 140, 141, 142, 143, 143, 144, 145, 146, 147,
+ 147, 148, 149, 150, 150, 151, 152, 153, 154, 154, 155, 156, 157,
+ 157, 158, 159, 160, 161, 161, 162, 163, 164, 164, 165, 166, 167,
+ 168, 168, 169, 170, 171, 171, 172, 173, 174, 175, 175, 176, 176,
+ 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 183,
+ 183, 184, 184, 185, 185, 186, 186, 187, 187, 188, 188, 189, 189,
+ 190, 191, 191, 192, 192, 193, 193, 194, 194, 195, 195, 196, 196,
+ 197, 197, 198, 198, 199, 199, 200, 200, 201, 201, 202, 202, 203,
+ 203, 204, 204, 205, 205, 206, 207, 207, 208, 208, 209, 209, 210,
+ 210, 211, 211, 212, 212, 213, 213, 214, 214, 215, 215, 216, 216,
+ 217, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 223, 223,
+ 224, 224, 225, 225, 226, 226, 227, 227, 228, 228, 229, 229, 230,
+ 230, 231, 231, 232, 232, 233, 233, 234, 234, 235, 235, 236, 236,
+ 237, 237, 238, 239, 239, 240, 240, 241, 241, 242, 242, 243, 243,
+ 244, 244, 245, 245, 246, 246, 247, 247, 248, 248, 249, 249, 250,
+ 250, 251, 251, 252, 252, 253, 253, 254, 255], dtype=numpy.int32)
+
+lookup_tables = [pw_255_lookup_table]
+
+def lookup_scale(img, m, b, table_idx=0, fill_in=DEFAULT_FILL_IN, fill_out=DEFAULT_FILL_OUT):
+ log.debug("Running 'lookup_scale'...")
+ lut = lookup_tables[table_idx]
+ img = linear_scale(img, m, b, fill_in=fill_in, fill_out=fill_out)
+ numpy.clip(img, 0, lut.shape[0]-1, out=img)
+ img = img.astype(numpy.uint32)
+ return lut[img]
+
+
def bt_scale_c(img, threshold, high_max, high_mult, low_max, low_mult, fill_in=DEFAULT_FILL_IN, fill_out=DEFAULT_FILL_OUT):
"""
this is a version of the brightness temperature scaling that is intended to work for data in celsius
@@ -299,6 +331,7 @@ def default_config_dir(self):
'ndvi' : ndvi_scale,
'distance' : passive_scale, # TODO, this is wrong... but we'll sort it out later?
'percent' : passive_scale, # TODO, this is wrong, find out what it should be
+ 'lookup' : lookup_scale,
}
@property
def known_rescale_kinds(self):
@@ -28,3 +28,19 @@ npp, viirs, m_nav, m, 13, btemp, btemp, 242.0,
npp, viirs, m_nav, m, 14, btemp, btemp, 242.0, 169620, 514, 107426, 257
npp, viirs, m_nav, m, 15, btemp, btemp, 242.0, 169620, 514, 107426, 257
npp, viirs, m_nav, m, 16, btemp, btemp, 242.0, 169620, 514, 107426, 257
+# crefl (applied over range -0.01 to 1.1)
+npp, viirs, m_nav, crefl, 01, corrected_reflectance, lookup, 59040.54, 590.4054
+npp, viirs, m_nav, crefl, 03, corrected_reflectance, lookup, 59040.54, 590.4054
+npp, viirs, m_nav, crefl, 04, corrected_reflectance, lookup, 59040.54, 590.4054
+npp, viirs, i_nav, crefl, 08, corrected_reflectance, lookup, 59040.54, 590.4054
+npp, viirs, m_nav, true_color_crefl, none, true_color_crefl, lookup, 59040.54, 590.4054
+aqua, modis, geo_1000m_nav,crefl, 01, corrected_reflectance, lookup, 59040.54, 590.4054
+aqua, modis, geo_250m_nav, crefl, 01, corrected_reflectance, lookup, 59040.54, 590.4054
+aqua, modis, geo_1000m_nav,crefl, 03, corrected_reflectance, lookup, 59040.54, 590.4054
+aqua, modis, geo_1000m_nav,crefl, 04, corrected_reflectance, lookup, 59040.54, 590.4054
+aqua, modis, geo_1000m_nav,true_color_crefl, none, true_color_crefl, lookup, 59040.54, 590.4054
+terra, modis, geo_1000m_nav,crefl, 01, corrected_reflectance, lookup, 59040.54, 590.4054
+terra, modis, geo_250m_nav, crefl, 01, corrected_reflectance, lookup, 59040.54, 590.4054
+terra, modis, geo_1000m_nav,crefl, 03, corrected_reflectance, lookup, 59040.54, 590.4054
+terra, modis, geo_1000m_nav,crefl, 04, corrected_reflectance, lookup, 59040.54, 590.4054
+terra, modis, geo_1000m_nav,true_color_crefl, none, true_color_crefl, lookup, 59040.54, 590.4054
@@ -71,3 +71,19 @@ terra, modis, geo_nav, inversion_strength, none, btemp,
terra, modis, geo_nav, inversion_depth, none, distance, raw
terra, modis, geo_nav, ice_concentration, none, percent, raw
+# crefl (applied over range -0.01 to 1.1)
+npp, viirs, m_nav, crefl, 01, corrected_reflectance, lookup, 229.73, 2.2973
+npp, viirs, m_nav, crefl, 03, corrected_reflectance, lookup, 229.73, 2.2973
+npp, viirs, m_nav, crefl, 04, corrected_reflectance, lookup, 229.73, 2.2973
+npp, viirs, i_nav, crefl, 08, corrected_reflectance, lookup, 229.73, 2.2973
+npp, viirs, m_nav, true_color_crefl, none, true_color_crefl, lookup, 229.73, 2.2973
+aqua, modis, geo_1000m_nav,crefl, 01, corrected_reflectance, lookup, 229.83, 2.2893
+aqua, modis, geo_250m_nav, crefl, 01, corrected_reflectance, lookup, 229.83, 2.2893
+aqua, modis, geo_1000m_nav,crefl, 03, corrected_reflectance, lookup, 229.83, 2.2893
+aqua, modis, geo_1000m_nav,crefl, 04, corrected_reflectance, lookup, 229.83, 2.2893
+aqua, modis, geo_1000m_nav,true_color_crefl, none, true_color_crefl, lookup, 229.83, 2.2983
+terra, modis, geo_1000m_nav,crefl, 01, corrected_reflectance, lookup, 229.83, 2.2893
+terra, modis, geo_250m_nav, crefl, 01, corrected_reflectance, lookup, 229.83, 2.2893
+terra, modis, geo_1000m_nav,crefl, 03, corrected_reflectance, lookup, 229.83, 2.2893
+terra, modis, geo_1000m_nav,crefl, 04, corrected_reflectance, lookup, 229.83, 2.2893
+terra, modis, geo_1000m_nav,true_color_crefl, none, true_color_crefl, lookup, 229.83, 2.2983
@@ -28,3 +28,19 @@ npp, viirs, m_nav, m, 13, btemp, btemp, 242.0,
npp, viirs, m_nav, m, 14, btemp, btemp, 242.0, 169620, 514, 107422.854, 256.987
npp, viirs, m_nav, m, 15, btemp, btemp, 242.0, 169620, 514, 107422.854, 256.987
npp, viirs, m_nav, m, 16, btemp, btemp, 242.0, 169620, 514, 107422.854, 256.987
+# crefl (applied over range -0.01 to 1.1)
+npp, viirs, m_nav, crefl, 01, corrected_reflectance, lookup, 59039.64, 590.3964
+npp, viirs, m_nav, crefl, 03, corrected_reflectance, lookup, 59039.64, 590.3964
+npp, viirs, m_nav, crefl, 04, corrected_reflectance, lookup, 59039.64, 590.3964
+npp, viirs, i_nav, crefl, 08, corrected_reflectance, lookup, 59039.64, 590.3964
+npp, viirs, m_nav, true_color_crefl, none, true_color_crefl, lookup, 59039.64, 590.3964
+aqua, modis, geo_1000m_nav,crefl, 01, corrected_reflectance, lookup, 59039.64, 590.3964
+aqua, modis, geo_250m_nav, crefl, 01, corrected_reflectance, lookup, 59039.64, 590.3964
+aqua, modis, geo_1000m_nav,crefl, 03, corrected_reflectance, lookup, 59039.64, 590.3964
+aqua, modis, geo_1000m_nav,crefl, 04, corrected_reflectance, lookup, 59039.64, 590.3964
+aqua, modis, geo_1000m_nav,true_color_crefl, none, true_color_crefl, lookup, 59039.64, 590.3964
+terra, modis, geo_1000m_nav,crefl, 01, corrected_reflectance, lookup, 59039.64, 590.3964
+terra, modis, geo_250m_nav, crefl, 01, corrected_reflectance, lookup, 59039.64, 590.3964
+terra, modis, geo_1000m_nav,crefl, 03, corrected_reflectance, lookup, 59039.64, 590.3964
+terra, modis, geo_1000m_nav,crefl, 04, corrected_reflectance, lookup, 59039.64, 590.3964
+terra, modis, geo_1000m_nav,true_color_crefl, none, true_color_crefl, lookup, 59039.64, 590.3964
@@ -28,3 +28,19 @@ npp, viirs, m_nav, m, 13, btemp, btemp, 242.0,660
npp, viirs, m_nav, m, 14, btemp, btemp, 242.0,660,2,414.854,0.987
npp, viirs, m_nav, m, 15, btemp, btemp, 242.0,660,2,414.854,0.987
npp, viirs, m_nav, m, 16, btemp, btemp, 242.0,660,2,414.854,0.987
+# crefl (applied over range -0.01 to 1.1)
+npp, viirs, m_nav, crefl, 01, corrected_reflectance, lookup, 228.83, 2.2883
+npp, viirs, m_nav, crefl, 03, corrected_reflectance, lookup, 228.83, 2.2883
+npp, viirs, m_nav, crefl, 04, corrected_reflectance, lookup, 228.83, 2.2883
+npp, viirs, i_nav, crefl, 08, corrected_reflectance, lookup, 228.83, 2.2883
+npp, viirs, m_nav, true_color_crefl, none, true_color_crefl, lookup, 228.83, 2.2883
+aqua, modis, geo_1000m_nav,crefl, 01, corrected_reflectance, lookup, 228.83, 2.2883
+aqua, modis, geo_250m_nav, crefl, 01, corrected_reflectance, lookup, 228.83, 2.2883
+aqua, modis, geo_1000m_nav,crefl, 03, corrected_reflectance, lookup, 228.83, 2.2883
+aqua, modis, geo_1000m_nav,crefl, 04, corrected_reflectance, lookup, 228.83, 2.2883
+aqua, modis, geo_1000m_nav,true_color_crefl, none, true_color_crefl, lookup, 228.83, 2.2883
+terra, modis, geo_1000m_nav,crefl, 01, corrected_reflectance, lookup, 228.83, 2.2883
+terra, modis, geo_250m_nav, crefl, 01, corrected_reflectance, lookup, 228.83, 2.2883
+terra, modis, geo_1000m_nav,crefl, 03, corrected_reflectance, lookup, 228.83, 2.2883
+terra, modis, geo_1000m_nav,crefl, 04, corrected_reflectance, lookup, 228.83, 2.2883
+terra, modis, geo_1000m_nav,true_color_crefl, none, true_color_crefl, lookup, 228.83, 2.2883
Oops, something went wrong.

0 comments on commit 1523647

Please sign in to comment.