def rinexobs(obsfn,writeh5=None,maxtimes=None): stem,ext = splitext(expanduser(obsfn)) if ext[-1].lower() == 'o': #raw text file with open(obsfn,'r') as rinex: header,verRinex = readHead(rinex) print('{} is a RINEX {} file.'.format(obsfn,verRinex)) (svnames,ntypes,obstimes,maxsv,obstypes) = makeSvSet(header,maxtimes,verRinex) blocks = makeBlocks(rinex,ntypes,maxsv,svnames,obstypes,obstimes) #%% save to disk (optional) if writeh5: h5fn = stem + '.h5' print('saving OBS data to {}'.format(h5fn)) blocks.to_hdf(h5fn,key='OBS',mode='a',complevel=6,append=False) elif ext.lower() == '.h5': blocks = read_hdf(obsfn,key='OBS') print('loaded OBS data from {} to {}'.format(blocks.items[0],blocks.items[-1])) return blocks
def rinexobs(obsfn,odir=None,maxtimes=None): obsfn = Path(obsfn).expanduser() if odir: odir = Path(odir).expanduser() if obsfn.suffix.lower().endswith('o'): #raw text file with obsfn.open('r') as rinex: header,verRinex = readHead(rinex) print('{} is a RINEX {} file.'.format(obsfn,verRinex)) (svnames,ntypes,obstimes,maxsv,obstypes) = makeSvSet(header,maxtimes,verRinex) blocks = makeBlocks(rinex,ntypes,maxsv,svnames,obstypes,obstimes) #%% save to disk (optional) if odir: h5fn = odir/obsfn.name.with_suffix('.h5') print('saving OBS data to {}'.format(h5fn)) blocks.to_hdf(h5fn,key='OBS',mode='a',complevel=6,append=False) elif obsfn.suffix.lower().endswith('.h5'): blocks = read_hdf(obsfn,key='OBS') print('loaded OBS data from {} to {}'.format(blocks.items[0],blocks.items[-1])) return blocks
c = 299792458 #[m/s] isrcoeff = e**3 * B0 * np.cos(alpha) / (2 * eps0 * me**2 * omega**2 * c) print('The ISR coefficient from Shpynev and Khabituev 2012 is {:.3e}'.format(isrcoeff)) return isrcoeff*np.trapz(Ne, slantrange) if __name__ == '__main__': syr=2014; smo=10; sdy = 15 dates = makeDates(syr,smo,sdy) tic = time() satdata = loopsat(tlefn,dates,obslla) print('{:.1f} seconds to compute orbits'.format(time()-tic)) tic = time() beamisr = read_hdf(beamfn,'data') satdata = findIntersection(satdata,beamisr,dates,beamfn,maxangdist) print('{:.1f} seconds to compute intersections'.format(time()-tic)) #only examine files from the correct date syrstr=str(syr)[2:] flist = glob(join(datadir,'pfa{}{}{}*.h5'.format(syrstr,smo,sdy))) for f in flist: tic = time() #TODO keep the results for each file in a list or something--right now tecisr #is computed for each file but then overwritten by the next file tecisr = checkFile(f,satdata,beamisr,maxdtsec) print('{:.1f} sec. to compute TEC for {} times in {}'.format(time()-tic,tecisr.shape[1],f))
def test_nav(): truthnav = read_hdf(str(rdir/'tests/demo.h5'),key='NAV') testnav = readRinexNav(str(rdir/'tests/demo.10n')) assert_allclose(testnav,truthnav)
def test_obs(): truth = read_hdf(str(rdir/'tests/demo.h5'),key='OBS') blocks = rinexobs(str(rdir/'tests/demo.10o')) assert_allclose(blocks,truth)
import os import sys from pandas.io.pytables import read_hdf from treedict import TreeDict sys.path.extend([os.path.join(os.path.dirname(__file__), '..')]) from paths import paths extrap = TreeDict() '''Datasets''' psid = read_hdf(os.path.join(paths.data, 'data.h5'), 'psid-labor') cnlsy = read_hdf(os.path.join(paths.data, 'data.h5'), 'cnlsy-labor') nlsy = read_hdf(os.path.join(paths.data, 'data.h5'), 'nlsy-labor') interp = read_hdf(os.path.join(paths.data, 'data.h5'), 'interp-labor') extrap = read_hdf(os.path.join(paths.data, 'data.h5'), 'extrap-labor') abcd = read_hdf(os.path.join(paths.data, 'data.h5'), 'abc-mini')
#!/usr/bin/env python """ Self-test file, registration case for OBS RINEX reader Michael Hirsch """ from pandas.io.pytables import read_hdf from numpy.testing import assert_allclose # from pyrinex.readRinexObs import rinexobs from pyrinex.readRinexNav import readRinexNav #%% do registration case truth = read_hdf('test/demo.h5', key='OBS') blocks = rinexobs('test/demo.10o', False, None) assert_allclose(blocks, truth) #%% truthnav = read_hdf('test/demo.h5', key='NAV') testnav = readRinexNav('test/demo.10n', False) assert_allclose(testnav, truthnav)
import os import sys from pandas.io.pytables import read_hdf from treedict import TreeDict sys.path.extend([os.path.join(os.path.dirname(__file__), '..')]) from paths import paths extrap = TreeDict() '''Datasets''' psid = read_hdf(os.path.join(paths.data, 'data.h5'), 'psid-labor') cnlsy = read_hdf(os.path.join(paths.data, 'data.h5'), 'cnlsy-labor') nlsy = read_hdf(os.path.join(paths.data, 'data.h5'), 'nlsy-labor') interp = read_hdf(os.path.join(paths.data, 'data.h5'), 'interp-labor') extrap = read_hdf(os.path.join(paths.data, 'data.h5'), 'extrap-labor') abcd = read_hdf(os.path.join(paths.data, 'data.h5'), 'abc-mini')
def test_nav(): truthnav = read_hdf(str(rdir / 'tests/demo.h5'), key='NAV') testnav = readRinexNav(str(rdir / 'tests/demo.10n')) assert_allclose(testnav, truthnav)
def test_obs(): truth = read_hdf(str(rdir / 'tests/demo.h5'), key='OBS') blocks = rinexobs(str(rdir / 'tests/demo.10o')) assert_allclose(blocks, truth)
def reader(path): with HDFStore(path) as store: return read_hdf(store, "df")
def test_pickle_path_localpath(setup_path): df = tm.makeDataFrame() result = tm.round_trip_pathlib( lambda p: df.to_hdf(p, "df"), lambda p: read_hdf(p, "df") ) tm.assert_frame_equal(df, result)
#!/usr/bin/env python """ Self-test file, registration case for OBS RINEX reader Michael Hirsch """ from pandas.io.pytables import read_hdf from numpy.testing import assert_allclose # from pyrinex.readRinexObs import rinexobs from pyrinex.readRinexNav import readRinexNav #%% do registration case truth = read_hdf('test/demo.h5',key='OBS') blocks = rinexobs('test/demo.10o',False,None) assert_allclose(blocks,truth) #%% truthnav = read_hdf('test/demo.h5',key='NAV') testnav = readRinexNav('test/demo.10n',False) assert_allclose(testnav,truthnav)