OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
obpg_data_file.py
Go to the documentation of this file.
1 """
2 Class to hold data about OBPG data files and allow sorting, etc. of those files.
3 """
4 
5 __author__ = 'melliott'
6 
7 import datetime
8 
9 class ObpgDataFile(object):
10  """
11  A class for holding data about OBPG data files.
12  """
13  def __init__(self, fname, ftype, sensr, stime, etime, meta=None):
14  self.name = fname
15  self.file_type = ftype
16  self.sensor = sensr
17  self.start_time = stime
18  self.end_time = etime
19  self.metadata = meta
20 
21  def __cmp__(self, other):
22  """
23  Compares 2 data files by comparing their start times. The file with
24  the earlier start time should be "less" than the other file.
25  """
26  self_st = datetime.datetime.strptime(self.start_time, '%Y%j%H%M%S')
27  other_st = datetime.datetime.strptime(other.start_time, '%Y%j%H%M%S')
28  if self_st < other_st:
29  return -1
30  elif self_st == other_st:
31  return 0
32  else:
33  return 1
34 
35  def __repr__(self):
36  return self.name
37 
38  def __str__(self):
39  return self.name
def __init__(self, fname, ftype, sensr, stime, etime, meta=None)