OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
processing_rules.py
Go to the documentation of this file.
1 
2 """
3 This module defines the classes needed for defining rules and rules sets for
4 the "uber" processor.
5 """
6 
7 __author__ = 'melliott'
8 
9 import collections
10 
11 Rule = collections.namedtuple('Rule', ['target_type', 'src_file_types',
12  'action', 'requires_batch',
13  'requires_all_sources'])
14 
15 def build_rule(targ_typ, src_types, actn, req_batch = False,
16  req_all_src = True):
17  """
18  Create and return a rule, using defaults for requires_batch and
19  requires_all_sources if no values are provided.
20  """
21  rule = Rule(targ_typ, src_types, actn, req_batch, req_all_src)
22  return rule
23 
24 # class Rule():
25 # """
26 # Rule contains the data needed to create one target from its sources.
27 # """
28 # def __init__(self, targt, src_types, actn, req_batch=False,
29 # req_all_src = True):
30 # self.target_type = targt
31 # self.src_file_types = src_types
32 # self.action = actn
33 # self.requires_batch = req_batch
34 # self.requires_all_sources = req_all_src
35 #
36 # # def __repr__(self):
37 # # return "Rule to convert: {0} to {1} using {2}".format(
38 # # str(self.src_file_types), self.target_type, self.action)
39 #
40 # def __str__(self):
41 # return "{0} <- {1}".format(self.target_type, str(self.src_file_types))
42 
43 
44 
45 class RuleSet():
46  """
47  Ruleset contains all the rules for a given instrument.
48  """
49  def __init__(self, rs_name, ruls, ordr, needs_geo=False):
50  self.name = rs_name
51  self.rules = ruls
52  self.order = ordr
53  self.requires_geo = needs_geo
54 
55  #def _list_members_in(l1, l2):
56  # members_in = []
57  # for el in l1:
58  # if el in l2:
59  # members_in.append(el)
60  # return members_in
61 
62  def find_target_type(self, target_type):
63  """
64  Find the index of the target type specified by target_type.
65  """
66  ndx = 0
67  found = False
68  while (ndx < len(self.order)):
69  if target_type == self.order[ndx]:
70  found = True
71  break
72  else:
73  ndx += 1
74  if not found:
75  ndx = -1
76  if target_type in self.order:
77  ndx = self.order.index(target_type)
78  else:
79  ndx = -1
80  return ndx
81 
82  def can_process(self, target_type, source_types):
83  """
84  Determine if a target type can be created from the given source types.
85  """
86  return True
87  if target_type in self.rules:
88  srcs_fnd = 0
89  for src_type in source_types:
90  if src_type in self.rules:
91  srcs_fnd += 1
92  # Todo: add (recursive) code to search "further back" in
93  # the sources of sources, etc. to see if we can process this.
94  if srcs_fnd == len(self.rules):
95  return True
96  else:
97  return False
an array had not been initialized Several spelling and grammar corrections were which is read from the appropriate MCF the above metadata values were hard coded A problem calculating the average background DN for SWIR bands when the moon is in the space view port was corrected The new algorithm used to calculate the average background DN for all reflective bands when the moon is in the space view port is now the same as the algorithm employed by the thermal bands For non SWIR changes in the averages are typically less than Also for non SWIR the black body DNs remain a backup in case the SV DNs are not available For SWIR the changes in computed averages were larger because the old which used the black body suffered from contamination by the micron leak As a consequence of the if SV DNs are not available for the SWIR the EV pixels will not be the granule time is used to identify the appropriate tables within the set given for one LUT the first two or last two tables respectively will be used for the interpolation If there is only one LUT in the set of it will be treated as a constant LUT The manner in which Earth View data is checked for saturation was changed Previously the raw Earth View DNs and Space View DNs were checked against the lookup table values contained in the table dn_sat The change made is to check the raw Earth and Space View DNs to be sure they are less than the maximum saturation value and to check the Space View subtracted Earth View dns against a set of values contained in the new lookup table dn_sat_ev The metadata configuration and ASSOCIATEDINSTRUMENTSHORTNAME from the MOD02HKM product The same metatdata with extensions and were removed from the MOD021KM and MOD02OBC products ASSOCIATEDSENSORSHORTNAME was set to MODIS in all products These changes are reflected in new File Specification which users may consult for exact the pow functions were eliminated in Emissive_Cal and Emissive bands replaced by more efficient code Other calculations throughout the code were also made more efficient Aside from a few round off there was no difference to the product The CPU time decreased by about for a day case and for a night case A minor bug in calculating the uncertainty index for emissive bands was corrected The frame index(0-based) was previously being used the frame number(1-based) should have been used. There were only a few minor changes to the uncertainty index(maximum of 1 digit). 3. Some inefficient arrays(Sigma_RVS_norm_sq) were eliminated and some code lines in Preprocess_L1A_Data were moved into Process_OBCEng_Emiss. There were no changes to the product. Required RAM was reduced by 20 MB. Now
def __init__(self, rs_name, ruls, ordr, needs_geo=False)
def find_target_type(self, target_type)
def can_process(self, target_type, source_types)
def build_rule(targ_typ, src_types, actn, req_batch=False, req_all_src=True)