コード例 #1
0
    def altaz(self):
        '''
        outputs RM data from altaz calculation

        Returns
        -------
        tuple:
            array[float]: parallel B field array
            array[float]: RM data
            array[float]: RM error data
        '''
        rm_s = []
        drm_s = []
        b_para_s = []

        alt_src, az_src = self._hp_arr()
        zen_src = 90. - alt_src

        for date in self.times:
            date_str, _, _ = str(date).partition('T')
            RM_dir = self.make_rm_dir(date_str)
            year, month, day = map(int, date_str.split('-'))
            tec_hp, rms_hp, ion_height = self.ionex_data(year, month, day)

            coord_lat, coord_lon, az_punct, zen_punct = phys.ipp(
                self.lat_str, self.lon_str, az_src, zen_src, ion_height)
            #XXX B_para calculated per DAY
            B_para = phys.B_IGRF(year, month, day, coord_lat, coord_lon,
                                 ion_height, az_punct, zen_punct)

            RMs = []
            dRMs = []
            for ui, UT in enumerate(self.UTs):
                hour = utils.std_hour(UT)
                radec_file = os.path.join(RM_dir,
                                          'radec{hour}.txt'.format(hour=hour))
                utils.write_radec(UT, radec_file, alt_src, az_src, date_str,
                                  self.location)
                #UTs are integer distances apart. Would an enumeration be better?
                TEC_path, RMS_TEC_path = itp.get_los_tec(
                    tec_hp[ui], rms_hp[ui], coord_lat, coord_lon, zen_punct)

                new_file = os.path.join(RM_dir,
                                        'IonRM{hour}.txt'.format(hour=hour))
                utils.write_RM(hour, new_file, B_para, TEC_path, RMS_TEC_path)

                _, _, _, RM_ut, dRM_ut = np.loadtxt(new_file, unpack=True)
                RMs.append(RM_ut)
                dRMs.append(dRM_ut)

            rm_s.append(RMs)
            drm_s.append(dRMs)
            b_para_s.append(B_para)

        self.RMs = np.array(rm_s)
        self.dRMs = np.array(drm_s)
        self.B_paras = np.array(b_para_s)
コード例 #2
0
ファイル: rm.py プロジェクト: jaguirre/radionopy
    def altaz(self):
        """
        outputs RM data from altaz calculation

        Returns
        -------
        tuple:
            array[float]: parallel B field array
            array[float]: RM data
            array[float]: RM error data
        """
        rm_s = []
        drm_s = []
        b_para_s = []

        alt_src, az_src = self._hp_arr()
        zen_src = 90.0 - alt_src

        for date in self.times:
            date_str, _, _ = str(date).partition("T")
            RM_dir = self.make_rm_dir(date_str)
            year, month, day = map(int, date_str.split("-"))
            tec_hp, rms_hp, ion_height = self.ionex_data(year, month, day)

            coord_lat, coord_lon, az_punct, zen_punct = phys.ipp(
                self.lat_str, self.lon_str, az_src, zen_src, ion_height
            )
            # XXX B_para calculated per DAY
            B_para = phys.B_IGRF(year, month, day, coord_lat, coord_lon, ion_height, az_punct, zen_punct)

            RMs = []
            dRMs = []
            for UT in self.UTs:
                hour = utils.std_hour(UT)
                radec_file = os.path.join(RM_dir, "radec{hour}.txt".format(hour=hour))
                utils.write_radec(UT, radec_file, alt_src, az_src, date_str, self.location)

                TEC_path, RMS_TEC_path = itp.get_los_tec(tec_hp[UT], rms_hp[UT], coord_lat, coord_lon, zen_punct)

                new_file = os.path.join(RM_dir, "IonRM{hour}.txt".format(hour=hour))
                utils.write_RM(hour, new_file, B_para, TEC_path, RMS_TEC_path)

                _, _, _, RM_ut, dRM_ut = np.loadtxt(new_file, unpack=True)
                RMs.append(RM_ut)
                dRMs.append(dRM_ut)

            rm_s.append(RMs)
            drm_s.append(dRMs)
            b_para_s.append(B_para)

        self.RMs = np.array(rm_s)
        self.dRMs = np.array(drm_s)
        self.B_paras = np.array(b_para_s)
コード例 #3
0
ファイル: rm.py プロジェクト: jaguirre/radionopy
    def get_radec_RM(self, ras, decs, verbose=False):
        # TODO: allow ra,dec to be floats, rather than arrays of floats
        # (to maintain single-pointing functionality)

        if not all((i <= 2.0 * np.pi and i >= 0.0) for i in ras):
            raise ValueError("All RAs must be between 0 and 2*pi radians")
        if not all((i <= np.pi / 2.0 and i >= -np.pi / 2.0) for i in decs):
            raise ValueError("All Decs must be between -pi/2 and pi/2 radians")

        self.coordinates_flag = "J2000_RaDec"

        for time in self.times:
            time_str, _, _ = str(time).partition("T")
            RM_dir = self.make_rm_dir(time_str)
            year, month, day = map(int, time_str.split("-"))
            if verbose:
                print(year, month, day)
            tec_hp, rms_hp, ion_height = self.ionex_data(year, month, day)

            # predict the ionospheric RM for every hour within a day
            for UT in self.UTs:
                hour = utils.std_hour(UT)
                c_icrs = SkyCoord(
                    ra=ras * u.radian,
                    dec=decs * u.radian,
                    location=self.location,
                    obstime=time + UT * u.hr,
                    frame="icrs",
                )
                c_altaz = c_icrs.transform_to("altaz")
                alt_src = np.array(c_altaz.alt.degree)
                az_src = np.array(c_altaz.az.degree)
                zen_src = np.array(Angle(c_altaz.zen).degree)  # AltAz.zen doesn't have method to return angle data

                coord_lat, coord_lon, az_punct, zen_punct = phys.ipp(
                    self.lat_str, self.lon_str, az_src, zen_src, ion_height
                )
                # XXX B_para calculated per UT
                B_para = phys.B_IGRF(year, month, day, coord_lat, coord_lon, ion_height, az_punct, zen_punct)

                TEC_path, RMS_TEC_path = itp.get_los_tec(tec_hp[UT], rms_hp[UT], coord_lat, coord_lon, zen_punct)

                new_file = os.path.join(RM_dir, "IonRM{hour}.txt".format(hour=hour))
                utils.write_RM(hour, new_file, B_para, TEC_path, RMS_TEC_path, write_to_file=True)

        b_para_s = []
        rm_s = []
        drm_s = []
        for time in self.times:
            time_str, _, _ = str(time).partition("T")
            RM_add = []
            dRM_add = []
            RM_dir = os.path.join(self.rm_dir, "{date}".format(date=time_str))

            for UT in self.UTs:
                data_file = os.path.join(RM_dir, "IonRM{hour}.txt".format(hour=utils.std_hour(UT)))
                _, _, B_para, RM_ut, dRM_ut = np.loadtxt(data_file, unpack=True)
                b_para_s.append(B_para)
                RM_add.append(RM_ut)
                dRM_add.append(dRM_ut)
            rm_s.append(RM_add)
            drm_s.append(dRM_add)

        self.B_para = np.array(b_para_s)
        self.RMs = np.array(rm_s)
        self.dRMs = np.array(drm_s)