def GPSRead(self,GPSloc): """ This function will read in the GPS data from ionofiles. It will assign the class variable GDGPS to the resultant GeoData object. Input GPSloc - The directory that holds all of the iono/h5 GeoData files. Can also be the filename of a mahali gps file """ self.numGD+=1 if GPSloc is None: return GPSloc = Path(GPSloc).expanduser() timelim=self.params['timebounds'] TEClist = [] ish5file = GPSloc.is_file() and GPSloc.suffix=='.h5' if ish5file: print('Reading in GPS Data') f = h5py.File(GPSloc, "r", libver='latest') siteinfo = f['sites'].value GPSNames = [i[0] for i in siteinfo] for isite in GPSNames: try: TECGD = GeoData(readMahalih5,(GPSloc,isite)) except Exception: TECGD = read_h5(os.path.join(GPSloc,isite)) if timelim is not None: TECGD.timereduce(timelim) if len(TECGD.times)==0: continue TEClist.append(TECGD) self.GPSNames = GPSNames self.GDGPS = TEClist print('Finished Reading in GPS Data') elif GPSloc.is_dir(): print('Reading in GPS Data') # Read in either iono files or h5 files TECfiles = GPSloc.glob('*.iono') funcname = readIonofiles if len(TECfiles) == 0: TECfiles = GPSloc.glob('*.h5') funcname = read_h5_main for ifile in TECfiles: TECGD = GeoData(funcname, str(ifile)) if timelim is not None: TECGD.timereduce(timelim) if len(TECGD.times)==0: continue TEClist.append(TECGD) # Determine the receiver names self.GPSNames = [os.path.splitext(os.path.split(i)[-1])[0].split('-')[0] for i in TECfiles] self.GDGPS = TEClist print('Finished Reading in GPS Data') else: print('GPS path is not a directory') return
def ISRRead(self,ISRloc): """ This function will read in the ISR data from SRI files or structured h5 files for GeoData. It will assign the class variable GDISR to the resultant GeoData object. Input ISRloc - This can be either a file from SRI or an h5 file thats been pre interpolated. """ if ISRloc is None: return ISRloc = Path(ISRloc).expanduser() if not ISRloc.is_file(): print('ISR Data is not a file') return self.numGD+=1 print('Reading in ISR Data') pnheights= self.params['paramheight'] paramstr = list(set([i[0] for i in pnheights])) try: SRIh5 = GeoData(readSRI_h5,(ISRloc,paramstr)) except Exception: try: SRIh5 = GeoData.read_h5(ISRloc) except Exception: return dt1ts,dt2ts = self.params['timebounds'] timelist = sp.where((SRIh5.times[:,1]>=dt1ts)&(SRIh5.times[:,0]<=dt2ts))[0] if len(timelist)==0: return SRIh5 = SRIh5.timeslice(timelist) hset = sp.array([i[1] for i in pnheights]) uh,uhs =sp.unique(hset,return_inverse=True) uh=uh*1e3 newcoordname = 'WGS84' if not (SRIh5.coordnames.lower() == newcoordname.lower()): changed_coords = SRIh5.__changecoords__(newcoordname) latmin,latmax = [changed_coords[:,0].min(),changed_coords[:,0].max()] lonmin,lonmax = [changed_coords[:,1].min(),changed_coords[:,1].max()] latvec = sp.linspace(latmin,latmax,self.params['ISRLatnum']) lonvec = sp.linspace(lonmin,lonmax,self.params['ISRLonnum']) LON,LAT = sp.meshgrid(lonvec,latvec) xycoords = sp.column_stack([LAT.flatten(),LON.flatten()]) # interpolation ncoords = xycoords.shape[0] uhall = sp.repeat(uh,ncoords) coords = sp.tile(xycoords,(len(uh),1)) coords = sp.column_stack((coords,uhall)) SRIh5.interpolate(coords,newcoordname,method='linear') self.GDISR = SRIh5 print('Finished Reading in ISR Data')
def ASRead(self,ASloc): """ This function will read in the All sky data from FITS files or structured h5 files for GeoData. Input ASloc - This can be either a directory holding the FITS files or a h5 file thats been pre interpolated. It will assign the class variable GDAS to the resultant GeoData object.""" if ASloc is None: return ASloc = Path(ASloc).expanduser() if not ASloc.is_dir() and not ASloc.is_file(): print('All Sky Data cannot be read') return self.numGD+=1 print('Reading in All sky data') wl = str(int(self.params['wl'])) wlstr ='*_0'+wl+'_*.FITS' interpsavedfile = ASloc/('interp'+wl+'.h5') reinterp=self.params['reinterp'] timelim=self.params['timebounds'] if self.nointerp: flist558 = sorted(ASloc.glob(wlstr)) self.GDAS = GeoData(readAllskyFITS,(flist558, ('PKR_DASC_20110112_AZ_10deg.FITS', 'PKR_DASC_20110112_EL_10deg.FITS'), 150.,timelim)) return if reinterp or not ASloc.is_file(): # pfalla = sp.array([65.136667,-147.447222,689.]) flist558 = sorted(ASloc.glob(wlstr)) if not flist558: return allsky_data = GeoData(readAllskyFITS,(flist558,('PKR_DASC_20110112_AZ_10deg.FITS','PKR_DASC_20110112_EL_10deg.FITS'),150.,timelim)) if timelim is not None: allsky_data.timereduce(timelim) xcoords = allsky_data.__changecoords__('WGS84') latlim=[xcoords[:,0].min(),xcoords[:,0].max()] lonlim=[xcoords[:,1].min(),xcoords[:,1].max()] nlat = 256 nlon = 256 latvec = sp.linspace(latlim[0],latlim[1],nlat) lonvec = sp.linspace(lonlim[0],lonlim[1],nlon) [LATM,LONM] = sp.meshgrid(latvec,lonvec) newcoords = sp.column_stack((LATM.flatten(),LONM.flatten(),150.*sp.ones(LONM.size))) allsky_data.interpolate(newcoords,'WGS84',method='linear',twodinterp=True) allsky_data.write_h5(interpsavedfile) else: allsky_data = GeoData.read_h5(ASloc) if timelim is not None: allsky_data.timereduce(timelim) self.GDAS = allsky_data print('Finished Reading in Allsky Data')