Permalink
Browse files

adding a zero cut off for all non-navigational variables

  • Loading branch information...
1 parent cd6c2f0 commit f11cbd35f31c1f0f95db81295a4bcd3a76c165f0 Eva Schiffer committed Feb 21, 2014
Showing with 10 additions and 1 deletion.
  1. +3 −0 stg/modis_guidebook.py
  2. +7 −1 stg/modis_io.py
View
@@ -59,6 +59,9 @@
"""
CLOUD_EFF_RADIUS_NAME = ('Effective_Particle_Radius', 'Cloud_Effective_Radius')
+# a list of our navigation variables
+NAVIGATION_VAR_NAMES = [LONGITUDE_NAME, LATITUDE_NAME, SOLAR_ZENITH_NAME, SENSOR_ZENITH_NAME]
+
# important attribute names
SCALE_ATTR_NAME = 'scale_factor'
ADD_OFFSET_ATTR_NAME = 'add_offset'
View
@@ -80,7 +80,8 @@ def load_variable_from_file (variable_name, file_path=None, file_object=None,
fill_value_name=modis_guidebook.FILL_VALUE_ATTR_NAME,
scale_name=modis_guidebook.SCALE_ATTR_NAME,
offset_name=modis_guidebook.ADD_OFFSET_ATTR_NAME,
- data_type_for_output=numpy.float32) :
+ data_type_for_output=numpy.float32,
+ zero_cutoff_exceptions=modis_guidebook.NAVIGATION_VAR_NAMES) :
"""
load a given variable from a file path or file object
"""
@@ -125,6 +126,11 @@ def load_variable_from_file (variable_name, file_path=None, file_object=None,
raw_data_copy[fill_mask] = numpy.nan
fill_value = numpy.nan
+ # if appropriate, also cutoff any data that is less than zero
+ if variable_name not in zero_cutoff_exceptions :
+ negative_mask = raw_data_copy < 0 # note numpy.nan tests as less than zero too, but that's fine here
+ raw_data_copy[negative_mask] = numpy.nan
+
# we got all the info we need about that file
SDS.endaccess(variable_object)

0 comments on commit f11cbd3

Please sign in to comment.