コード例 #1
0
 def test_toutc(self):
     index = numpy.array([
         34656606509596782, 35184372097220718, 35220842678627438,
         35466003203796078
     ])
     datetime_x = pystare.to_utc_approximate(index)
     datetime_r = numpy.array(datetime_x, dtype='datetime64[ms]')
     numpy.testing.assert_array_equal(datetime, datetime_r)
コード例 #2
0
# Note cmp does the right thing.
print('')
for i in range(len(tim)):
    print('%3d i,tim %04d '%(i,tim[i]),' %02d:%02d '%merra2_make_time(0,tim[i]))

formatted_times = []
idx = np.zeros([tim.size],dtype=np.int64)
for i in range(len(tim)):
    yr,mo,dy = merra2_parse_begin_date(tim.begin_date)
    hr,mn    = merra2_make_time(0,tim[i])
    sc       = 0
    tm       = format_time(yr,mo,dy,hr,mn,sc)
    dt = np.array([tm],dtype='datetime64[ms]')
    idx[i]   = ps.from_utc(dt.astype(np.int64),resolution_level_1hr)
    # idx[i]   = ps.from_utc(dt.astype(np.int64),resolution_level_1o4hr)
    back     = np.array(ps.to_utc_approximate(np.array([idx[i]],dtype=np.int64)),dtype='datetime64[ms]')
    print(yr,mo,dy,hr,mn,tm,dt,hex(idx[i]),back)
    formatted_times.append(tm)

### GOES BAND_05 # Check time information

goes_b5_dataPath = "/home/mrilee/data/"
goes_b5_dataFile = "goes10.2005.349.003015.BAND_05.nc"
goes_b5_fqFilename = goes_b5_dataPath+goes_b5_dataFile
goes_b5_ds = Dataset(goes_b5_fqFilename)

# print('keys: ',goes_b5_ds.variables.keys())

tim = goes_b5_ds['time']
print('tim:                  ',tim)
print('tim units:            ',tim.units)
コード例 #3
0
 def test_epoch(self):
     datetime_x1 = datetime.astype(numpy.int64)
     index = pystare.from_utc(datetime_x1, 27)
     datetime_x2 = pystare.to_utc_approximate(index)
     numpy.testing.assert_array_equal(datetime_x1, datetime_x2)
コード例 #4
0
 def test_utc_roundtrip(self):
     index = pystare.from_utc(datetime.astype(numpy.int64), 27)
     datetime_x = pystare.to_utc_approximate(index)
     datetime_r = numpy.array(datetime_x, dtype='datetime64[ms]')
     numpy.testing.assert_array_equal(datetime, datetime_r)
コード例 #5
0
ファイル: geodata.py プロジェクト: SpatioTemporal/GeoData
def datetime_from_stare(tId):
  if type(tId) is np.ndarray:
    return np.array(ps.to_utc_approximate(tId),dtype='datetime64[ms]')
  return np.array(ps.to_utc_approximate(np.array([tId],dtype=np.int64)),dtype='datetime64[ms]')[0]