예제 #1
0
    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
예제 #2
0
    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')