ocssw V2020
hicoLonLatHdr.py
Go to the documentation of this file.
1 '''
2 Created on Dec 8, 2015
3 
4 @author: rhealy
5 '''
6 
7 code_version = 1.0
8 code_author = 'R. Healy (richard.healy@nasa.gov) SAIC'
9 code_name = 'proc_hico.py'
10 code_date = '12/9/2015'
11 
12 class hicoLonLatHdr():
13  '''
14  This is a hico Lon Lat Header class for constructing an
15  object to be passed to the writeHicoLonLatHdr function.
16  '''
17 
18 
19  def __init__(self,**kwargs):
20  '''
21  Constructor: Create the header class consisting of history
22  and various parameters written to the LonLat Hdr file.
23 
24  '''
25 
26  self.variables = kwargs
27 
28  def set_variable(self,k,v):
29  self.variables[k]= v
30 
31  def get_variable(self,k):
32  return self.variables.get(k,None)
33 
34  def createHistory(self,qinfo):
35 
36  import getpass
37  from datetime import date
38  from datetime import datetime
39  import socket
40  timenow = datetime.now()
41 
42 
43  history = {}
44 
45  history['geometry_code_version'] = code_version
46  history['geometry_code_date'] = code_date
47  history['geometry_code_author'] = code_author
48  history['geometry_code_name'] = code_name
49  history['geometry_code_SPosVelQuatCsv'] = qinfo['This file name']
50  history['geometry_source_csv_filename'] = qinfo['Source CSV file']
51  history['geometry_subset_csv_filename'] = qinfo['Subset CSV file']
52  history['geometry_run_date'] = date.today()
53  history['geometry_run_time'] = timenow.strftime("%H:%M:%S")
54  history['geometry_run_by'] = getpass.getuser()
55  history['geometry_run_on'] = socket.gethostname()
56  history['pvq_code_name'] = qinfo['Code name']
57  history['pvq_code_version'] = qinfo['Code version']
58  history['pvq_code_date'] = qinfo['Code date']
59  history['pvq_code_author'] = qinfo['Code author']
60  history['pvq_code_computer'] = qinfo['Code executed on computer']
61  history['pvq_code_username'] = qinfo['Code executed by username']
62 # history['pvq_code_IDL_family'] = qinfo['Code run under IDL osfamily']
63 # history['pvq_code_IDL_os'] = qinfo['Code run under IDL os']
64 # history['pvq_code_IDL_osname'] = qinfo['Code run under IDL osname']
65 # history['pvq_code_IDL_version'] = qinfo['Code run under IDL version']
66 # history['pvq_code_IDL_start_time'] = qinfo['Code start time']
67 # history['pvq_code_IDL_end_time'] = qinfo['Code end time']
68  history['geometry_hico_angle_in_degrees_from_stowed'] = qinfo['Theta (degrees from stowed position)']
69  history['geometry_sensor_orientation'] = qinfo['ISS orientation']
70  history['geometry_ISS_Z_direction'] = self.get_variable('geometry_ISS_Z_direction')
71  history['hico_exposure_interval_s'] = qinfo['Exposure interval (frame time)']
72  history['hico_trigger_pulse_width_s'] = qinfo['Trigger pulse width (s)']
73  history['iss_ODRC_broadcast_time-gps_time_s'] = qinfo['ODRC broadcast time - gps time (s)']
74  history['geometry_deltaUT1_s'] = self.get_variable('geometry_deltaUT1_s')
75  history['geometry_deltaT_s'] = self.get_variable('geometry_deltaT_s')
76  history['geometry_LOD'] = self.get_variable('geometry_LOD')
77  history['geometry_xp_rad'] = self.get_variable('geometry_xp_rad')
78  history['geometry_yp_rad'] = self.get_variable('geometry_yp_rad')
79  history['geometry_bore_sight_params'] = self.get_variable('geometry_bore_sight_params')
80 
81  self.history = history
82 
84 
85  fhdr = open(self.get_variable('filename'),"w")
86 
87  fhdr.write('ENVI\n')
88  fhdr.write('description = { ' + self.get_variable('description') + ' }\n')
89  for v in sorted(self.variables):
90  if v not in 'description':
91  fhdr.write('{} = {}\n'.format(v,self.variables[v]))
92 
93  fhdr.write('\nhistory = begins\n')
94 
95  for key in sorted(self.history.keys()):
96  fhdr.write('{} = {}\n'.format(key,self.history[key]))
97 
98  fhdr.write('\nhistory = ends\n')
99 
100  fhdr.close()
def __init__(self, **kwargs)