Example #1
0
 def test_sec2hms(self):
     """sec2hms should return a known value for known input"""
     inval = (
         (30, False, False),
         (86401, False, False),
         (86401, False, True),
         (30.3, True, False),
         (3599, False, False),
     )
     real_ans = ([0, 0, 30], [24, 0, 1], [0, 0, 1], [0, 0, 30], [0, 59, 59])
     with warnings.catch_warnings(record=True) as w:
         warnings.filterwarnings("always", "Number of seconds > seconds in day.*", UserWarning, "^spacepy\\.time")
         for i, val in enumerate(inval):
             ans = t.sec2hms(*val)
             self.assertEqual(real_ans[i], ans)
     self.assertEqual(1, len(w))
     self.assertEqual("Number of seconds > seconds in day. Try days keyword.", str(w[0].message))
     self.assertEqual(t.sec2hms(12, False, False, True), datetime.timedelta(seconds=12))
Example #2
0
 def test_sec2hms(self):
     """sec2hms should return a known value for known input"""
     inval = ((30, False, False), (86401, False, False),
              (86401, False, True), (30.3, True, False), (3599, False,
                                                          False))
     real_ans = ([0, 0, 30], [24, 0, 1], [0, 0, 1], [0, 0, 30], [0, 59, 59])
     with warnings.catch_warnings(record=True) as w:
         warnings.filterwarnings('always',
                                 'Number of seconds > seconds in day.*',
                                 UserWarning, '^spacepy\\.time')
         for i, val in enumerate(inval):
             ans = t.sec2hms(*val)
             self.assertEqual(real_ans[i], ans)
     self.assertEqual(1, len(w))
     self.assertEqual(
         'Number of seconds > seconds in day. Try days keyword.',
         str(w[0].message))
     self.assertEqual(t.sec2hms(12, False, False, True),
                      datetime.timedelta(seconds=12))
Example #3
0
### With CRRES database, extract position and time of the satellite (root of the database)
# define coordonates of the satellite
#pycdf.gAttrList(cdf)
#print cdf['Altitude'].attrs
Altitude=cdf['Altitude'][:]         # Altitude of the satellite (km) - coherent with perigee and apogee orbit type in description
radial_distance=Altitude/Re + 1             # radial distance of the satellite (R_e)
#print cdf['Latitude'].attrs
Latitude=cdf['Latitude'][:]         # Latitude of the satellite (degree) - is it in the GEO system ? - coherent with inclination orbit type in description
#print cdf['Longitude'].attrs
Longitude=cdf['Longitude'][:]         # Longitude of the satellite (degree) - is it in the GEO system ?

### Add survey data to find orbit number
temp1 = np.array(pd.DataFrame(orbit_survey, columns=['ORBIT'])).flatten().astype(float)
temp2=[tim.doy2date(1900+np.array(pd.DataFrame(orbit_survey, columns=['YR'])).flatten()[i],np.array(pd.DataFrame(orbit_survey, columns=['DOY'])).flatten()[i],dtobj=True)
 + tim.sec2hms(np.array(pd.DataFrame(orbit_survey, columns=['START'])).flatten()[i],rounding=False,days=False,dtobj=True) for i in range(len(temp1))]
orbit_dates = pd.Series(temp1, index=temp2)
orbit_dates = orbit_dates[~orbit_dates.index.duplicated(keep='first')]
orbit_epoch = pd.Series(np.nan, index=Epoch)
orbit_epoch = orbit_epoch[~orbit_epoch.index.duplicated(keep='first')]
# interpolate the orbits according to these two vectors
all_orbits=pd.concat([orbit_dates, orbit_epoch]).sort_index()
all_orbits = all_orbits[~all_orbits.index.duplicated(keep='first')]
all_orbits=all_orbits.interpolate(method='time')[Epoch]
orbit_number=np.array(pd.DataFrame(all_orbits, columns=['0'])).flatten()
#plt.plot(Epoch,orbit_number)
del temp1
del temp2
del orbit_dates
del orbit_epoch
del all_orbits