Example #1
0
class test_Weather:
    def setup(self):
        self.weather = Weather()
        pass

    def test_retrieve_zenith_opacity(self):
        zenith_tau = self.weather.retrieve_zenith_opacity(54210, 23.6e9)
        assert_almost_equal(zenith_tau, 0.1550, places=4)
        zenith_tau = self.weather.retrieve_zenith_opacity(54215.32, 23.6e9)
        assert_almost_equal(zenith_tau, 0.1246, places=4)
Example #2
0
class test_Weather:

    def setup(self):
        self.weather = Weather()
        pass
        
    def test_retrieve_zenith_opacity(self):
        zenith_tau = self.weather.retrieve_zenith_opacity(54210, 23.6e9)
        assert_almost_equal(zenith_tau, 0.1550, places=4)
        zenith_tau = self.weather.retrieve_zenith_opacity(54215.32, 23.6e9)
        assert_almost_equal(zenith_tau, 0.1246, places=4)
Example #3
0
def preview_zenith_tau(log, row_list, cl_params, feeds, windows, pols):

    # if using the weather database
    if not cl_params.zenithtau:

        foo = row_list.get(cl_params.mapscans[0], feeds[0], windows[0],
                           pols[0])
        ff = fitsio.FITS(cl_params.infilename)
        extension = foo['EXTENSION']
        row = foo['ROW'][0]
        bar = ff[extension]['OBSFREQ', 'DATE-OBS'][row]
        dateobs = bar['DATE-OBS'][0]
        obsfreq = bar['OBSFREQ'][0]
        ff.close()

        weather = Weather()
        pu = Pipeutils()

        mjd = pu.dateToMjd(dateobs)
        zenithtau = weather.retrieve_zenith_opacity(mjd, obsfreq)
        log.doMessage('INFO',
                      'Zenith opacity for map: {0:.3f}'.format(zenithtau))

    # else if set at the command line
    else:

        log.doMessage('INFO',
                      'Zenith opacity for '
                      'map: {0:.3f}'.format(cl_params.zenithtau))
Example #4
0
def preview_zenith_tau(log, row_list, cl_params, feeds, windows, pols):

    foo = None

    # if using the weather database
    if cl_params.zenithtau is None:
        for feed in feeds:
            for window in windows:
                for pol in pols:
                    try:
                        foo = row_list.get(cl_params.mapscans[0], feed, window,
                                           pol)
                        break  # if we found a row move on, otherwise try another feed/win/pol
                    except KeyError:
                        continue
        if not foo:
            log.doMessage('ERR',
                          'Could not find scan for zenith opacity preview')
            return

        ff = fitsio.FITS(cl_params.infilename)
        extension = foo['EXTENSION']
        row = foo['ROW'][0]
        bar = ff[extension]['OBSFREQ', 'DATE-OBS'][row]
        dateobs = bar['DATE-OBS'][0]
        obsfreq = bar['OBSFREQ'][0]
        ff.close()

        weather = Weather()
        pu = Pipeutils()

        mjd = pu.dateToMjd(dateobs)
        zenithtau = weather.retrieve_zenith_opacity(mjd, obsfreq, log)
        if zenithtau:
            log.doMessage(
                'INFO', 'Approximate zenith opacity for map: {0:.3f}'.format(
                    zenithtau))
        else:
            log.doMessage(
                'ERR', 'Not able to retrieve integration '
                'zenith opacity for calibration to:', cl_params.units,
                '\n  Please supply a zenith opacity or calibrate to Ta.')
            sys.exit(9)

    # else if set at the command line
    else:

        log.doMessage(
            'INFO', 'Zenith opacity for '
            'map: {0:.3f}'.format(cl_params.zenithtau))
Example #5
0
def preview_zenith_tau(log, row_list, cl_params, feeds, windows, pols):

    foo = None

    # if using the weather database
    if cl_params.zenithtau is None:
        for feed in feeds:
            for window in windows:
                for pol in pols:
                    try:
                        foo = row_list.get(cl_params.mapscans[0], feed, window, pol)
                        break  # if we found a row move on, otherwise try another feed/win/pol
                    except KeyError:
                        continue
        if not foo:
            log.doMessage('ERR', 'Could not find scan for zenith opacity preview')
            return

        ff = fitsio.FITS(cl_params.infilename)
        extension = foo['EXTENSION']
        row = foo['ROW'][0]
        bar = ff[extension]['OBSFREQ', 'DATE-OBS'][row]
        dateobs = bar['DATE-OBS'][0]
        obsfreq = bar['OBSFREQ'][0]
        ff.close()

        weather = Weather()
        pu = Pipeutils()

        mjd = pu.dateToMjd(dateobs)
        zenithtau = weather.retrieve_zenith_opacity(mjd, obsfreq, log)
        if zenithtau:
            log.doMessage('INFO',
                          'Approximate zenith opacity for map: {0:.3f}'.format(zenithtau))
        else:
            log.doMessage('ERR', 'Not able to retrieve integration '
                          'zenith opacity for calibration to:', cl_params.units,
                          '\n  Please supply a zenith opacity or calibrate to Ta.')
            sys.exit(9)

    # else if set at the command line
    else:

        log.doMessage('INFO',
                      'Zenith opacity for '
                      'map: {0:.3f}'.format(cl_params.zenithtau))