Virgo icon indicating copy to clipboard operation
Virgo copied to clipboard

Adding Meta parameter to virgo.plot throws error

Open davewyers opened this issue 2 years ago • 3 comments

Hi Apostolos

I have noticed that if you include the meta=True parameter to the virgo.plot command it throws an error. Removing the parameter works correctly.

meta (bool) – Display header with date, time, and target

print ('Generate Plot')
virgo.plot(
       obs_parameters=obs,
       n=20,
       m=35,
       f_rest=freq,
       obs_file=prefix+'_observation.dat',
       cal_file='/home/pi/astro/off.dat',
       power_csv=prefix+'_time_series.csv',
       dB=True,
       meta=True,
       spectra_csv=prefix+'_spectrum.csv',
       plot_file=prefix+'_plot.png')

Generate Plot Traceback (most recent call last): File "/home/pi/.local/lib/python3.9/site-packages/astropy/coordinates/angle_formats.py", line 302, in parse found_angle, found_unit = self._thread_local._parser.parse( File "/home/pi/.local/lib/python3.9/site-packages/astropy/utils/parsing.py", line 115, in parse return self.parser.parse(*args, **kwargs) File "/home/pi/.local/lib/python3.9/site-packages/astropy/extern/ply/yacc.py", line 333, in parse return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) File "/home/pi/.local/lib/python3.9/site-packages/astropy/extern/ply/yacc.py", line 1201, in parseopt_notrack tok = call_errorfunc(self.errorfunc, errtoken, self) File "/home/pi/.local/lib/python3.9/site-packages/astropy/extern/ply/yacc.py", line 192, in call_errorfunc r = errorfunc(token) File "/home/pi/.local/lib/python3.9/site-packages/astropy/coordinates/angle_formats.py", line 294, in p_error raise ValueError ValueError

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/pi/astro/karo2.py", line 119, in virgo.plot( File "/home/pi/.local/lib/python3.9/site-packages/virgo/virgo.py", line 710, in plot obs_location = EarthLocation.from_geodetic(loc[0], loc[1], loc[2]) File "/home/pi/.local/lib/python3.9/site-packages/astropy/coordinates/earth.py", line 297, in from_geodetic lon = Angle(lon, u.degree, copy=False).wrap_at(180 * u.degree) File "/home/pi/.local/lib/python3.9/site-packages/astropy/coordinates/angles.py", line 122, in new angle, angle_unit = form.parse_angle(angle, unit) File "/home/pi/.local/lib/python3.9/site-packages/astropy/coordinates/angle_formats.py", line 395, in parse_angle return _AngleParser().parse(angle, unit, debug=debug) File "/home/pi/.local/lib/python3.9/site-packages/astropy/coordinates/angle_formats.py", line 308, in parse raise ValueError( ValueError: Syntax error parsing angle '-'

davewyers avatar Aug 12 '22 04:08 davewyers

@kevinawilson Could you comment on this? I don't remember much from the meta implementation, but I don't fully understand this particular line of the commit.

Why was if vlsr changed to if vlsr or meta? Isn't that the cause of the error (considering the user did not provide a location)? @davewyers that's just an assumption, please confirm or deny whether the location was indeed not part of the observing parameters (obs_parameters=obs).

0xCoto avatar Aug 12 '22 14:08 0xCoto

Hi @0xCoto

The Lat and Long are defined in the file then called in the obs object.

Define observation parameters

obs = {
    'dev_args': '',
    'rf_gain': 10,
    'if_gain': 0,
    'bb_gain': 0,
    'frequency': freq,
    'bandwidth': 2.4e6,
    'channels': 2048,
    't_sample': 1,
    'duration': 240,
    'loc': str(lat) + ' ' + str(lon) + ' ' + str(height),
    'ra_dec': str(RA) + ' '+ str(DEC),
    'az_alt': str(az) + ' ' + str(alt)
 }

gal_l, gal_b = virgo.galactic(RA,DEC)
print ('Galactic l = '+str(gal_l))
print ('Galactic b = '+str(gal_b))
virgo.simulate(gal_l, gal_b, beamwidth, -400, 400, prefix+'_simulate.png')

print ('Observe run start')
virgo.observe(obs_parameters=obs, obs_file=prefix+'_observation.dat')
print ('Observe run end')

davewyers avatar Aug 12 '22 21:08 davewyers

I know this has been out there awhile but appears still an issue with recent, I've had success to change to recommended from EarthLocation changing to for geocentric; lon, lat, height for geodetic). Also note longitude is EAST only so 0 to 360

line 720 change order original obs_location = EarthLocation.from_geodetic(loc[0], loc[1], loc[2]) change obs_location = EarthLocation.from_geodetic(loc[1], loc[0], loc[2])

line 624 added this global to remove error spam added global mjd

line 145, 228 change order original loc = EarthLocation(lat=latu.deg, lon=lonu.deg, height=heightu.m) changed loc = EarthLocation(lon=lonu.deg, lat=latu.deg, height=heightu.m)

example obs

Define observation parameters

obs = { 'rf_gain': 15, 'if_gain': 5, 'bb_gain': 5, 'dev_args': '', 'frequency': 1420e6, 'bandwidth': 2.4e6, 'channels': 2048, 't_sample': 1, 'duration': 120, 'loc': [32.62, 233.39, 300.00], 'ra_dec': '', 'az_alt': [180, 60], 'spectrometer': 'FTF', 'obs_file': 'firstob.dat6' }

1

prestoeatstacos avatar Jul 08 '23 20:07 prestoeatstacos