OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
viirs_utils.py
Go to the documentation of this file.
1 from seadasutils.MetaUtils import readMetadata
2 import seadasutils.ProcUtils as ProcUtils
3 
4 def viirs_timestamp(arg):
5  """
6  Determine the start time, stop time, and platform of a VIIRS hdf5 file.
7  """
8 
9  meta = readMetadata(arg)
10  if 'Instrument_Short_Name' in meta:
11  sat_name = meta['Instrument_Short_Name'].lower()
12  sdate = meta['Beginning_Date']
13  edate = meta['Ending_Date']
14  stime = meta['Beginning_Time']
15  etime = meta['Ending_Time']
16  start_time = '-'.join([sdate[0:4],sdate[4:6],sdate[6:8]]) + 'T' + ':'.join([stime[0:2],stime[2:4],stime[4:len(stime)]])
17  end_time = '-'.join([edate[0:4],edate[4:6],edate[6:8]]) + 'T' + ':'.join([etime[0:2],etime[2:4],etime[4:len(etime)]])
18  elif 'platform' in meta:
19  sat_name = meta['platform'].lower()
20  start_time = meta['time_coverage_start']
21  end_time = meta['time_coverage_end']
22  # at this point datetimes are formatted as YYYY-MM-DD HH:MM:SS.uuuuuu
23 
24  # return values formatted as YYYYDDDHHMMSS
25  # return ( ProcUtils.date_convert(start_time, 't', 'j'),
26  # ProcUtils.date_convert(end_time, 't', 'j'),
27  # sat_name )
28  return ( start_time[0:19],
29  end_time[0:19],
30  sat_name )
def readMetadata(filename)
Definition: MetaUtils.py:201
def viirs_timestamp(arg)
Definition: viirs_utils.py:4