def test_hardware_file_not_found(self): """ Test if it raises an error for an non-existing hardware file """ with self.assertRaises( pydarn.radar_exceptions.HardwareFileNotFoundError): pydarn.read_hdw_file('dog')
def test_read_hdw_file_old_year(self): """ test if read_hdw_file can read McMurdo's older hardware file information """ hdw_data = pydarn.read_hdw_file('mcm', datetime(year=2016, month=1, day=1)) self.assertEqual(hdw_data.abbrev, 'mcm') self.assertEqual(hdw_data.stid, 20) self.assertEqual(hdw_data.geographic.lat, -77.880) self.assertEqual(hdw_data.geographic.lon, 166.730) self.assertEqual(hdw_data.geographic.alt, 300.0) self.assertEqual(hdw_data.boresight, 263.4) self.assertEqual(hdw_data.beam_seperation, 3.24) self.assertEqual(hdw_data.velocity_sign, 1) self.assertEqual(hdw_data.rx_attenuator, 10) self.assertEqual(hdw_data.tdiff, 0.0) self.assertEqual(hdw_data.phase_sign, 1) self.assertEqual(hdw_data.interferometer_offset.x, 0.0) self.assertEqual(hdw_data.interferometer_offset.y, 70.1) self.assertEqual(hdw_data.interferometer_offset.z, -4.1) self.assertEqual(hdw_data.rx_rise_time, 0.0) self.assertEqual(hdw_data.attenuation_stages, 2) self.assertEqual(hdw_data.gates, 75) self.assertEqual(hdw_data.beams, 16)
def test_read_hdw_file(self): """ test if read_hdw_file can read Saskatoon's most current hardware information """ hdw_data = pydarn.read_hdw_file('sas') self.assertEqual(hdw_data.abbrev, 'sas') self.assertEqual(hdw_data.stid, 5) self.assertEqual(hdw_data.geographic.lat, 52.160) self.assertEqual(hdw_data.geographic.lon, -106.530) self.assertEqual(hdw_data.geographic.alt, 494.0) self.assertEqual(hdw_data.boresight, 23.1) self.assertEqual(hdw_data.beam_seperation, 3.24) self.assertEqual(hdw_data.velocity_sign, 1) self.assertEqual(hdw_data.rx_attenuator, 10) self.assertEqual(hdw_data.tdiff, 0.000) self.assertEqual(hdw_data.phase_sign, 1) self.assertEqual(hdw_data.interferometer_offset.x, 0.0) self.assertEqual(hdw_data.interferometer_offset.y, -100.0) self.assertEqual(hdw_data.interferometer_offset.z, 0.0) self.assertEqual(hdw_data.rx_rise_time, 0.0) self.assertEqual(hdw_data.attenuation_stages, 0) self.assertEqual(hdw_data.gates, 225) self.assertEqual(hdw_data.beams, 16)
def geolocate_radar_fov(rad, time=None): """ Geolocate each range cell Input parameters ---------------- rad <str>: Radar code time <datetime> (optional): datetime object to calculate magnetic cordinates Return parameters ----------------- _dict_ { beams <list(int)>: Beams gates <list(int)>: Gates glat [beams, gates] <np.float>: Geogarphic latitude glon [beams, gates] <np.float>: Geogarphic longitude azm [beams, gates] <np.float>: Geogarphic azimuth of ray-bearing mlat [beams, gates] <np.float>: Magnetic latitude mlon [beams, gates] <np.float>: Magnetic longitude mazm [beams, gates] <np.float>: Magnetic azimuth of ray-bearing } Calling sequence ---------------- from geopos import geolocate_radar_fov _dict_ = geolocate_radar_fov("bks") """ logger.info(f"Geolocate radar ({rad}) FoV") hdw = pydarn.read_hdw_file(rad) fov_obj = rad_fov.CalcFov(hdw=hdw, altitude=300.) blen, glen = hdw.beams, hdw.gates if glen >= 110: glen = 110 glat, glon, azm = np.zeros((blen, glen)), np.zeros((blen, glen)), np.zeros( (blen, glen)) mlat, mlon, mazm = np.zeros((blen, glen)) * np.nan, np.zeros( (blen, glen)) * np.nan, np.zeros((blen, glen)) * np.nan for i, b in enumerate(range(blen)): for j, g in enumerate(range(glen)): if j < 110: glat[i, j], glon[i, j] = fov_obj.latCenter[b, g], fov_obj.lonCenter[b, g] d = geoPack.calcDistPnt(fov_obj.latFull[b, g], fov_obj.lonFull[b, g], 300, distLat=fov_obj.latFull[b, g + 1], distLon=fov_obj.lonFull[b, g + 1], distAlt=300) azm[i, j] = d["az"] if time is not None: mlat[i, j], mlon[i, j], _ = aacgmv2.convert_latlon( fov_obj.latFull[b, g], fov_obj.lonFull[b, g], 300., time, method_code="G2A") mlat2, mlon2, _ = aacgmv2.convert_latlon( fov_obj.latFull[b, g + 1], fov_obj.lonFull[b, g + 1], 300., time, method_code="G2A") d = geoPack.calcDistPnt(mlat[i, j], mlon[i, j], 300, distLat=mlat2, distLon=mlon2, distAlt=300) mazm[i, j] = d["az"] _dict_ = { "beams": range(blen), "gates": range(glen), "glat": glat, "glon": glon, "azm": azm, "mlat": mlat, "mlon": mlon, "mazm": mazm } return _dict_