plot_grid with KeyError: 'vector.mlat'
Closed this issue · 4 comments
Hi ,
I try to plot grid file as below
import matplotlib.pyplot as plt
import datetime as dt
import pydarn
stime = dt.datetime(2020, 1, 1, 0,0)
grid_file = "20200101.0000.00.jme.grd"
grid_data = pydarn.SuperDARNRead(grid_file).read_grid()
pydarn.Grid.plot_grid(grid_data, start_time=stime)
and get below error messages:
Traceback (most recent call last):
File "plot_grid.py", line 13, in <module>
pydarn.Grid.plot_grid(grid_data, start_time=stime)
File "/opt/simplehpc/miniconda3/lib/python3.7/site-packages/pydarn/plotting/grid.py", line 173, in plot_grid
dmap_data[record]['vector.mlat'][0]))
KeyError: 'vector.mlat'
The grid file I make with "make_grid -vb 20200101.0000.00.jme.fitacf > 20200101.0000.00.jme.grd"
Pydarn version:
pydarn 3.1.1
pydarnio 1.2.1
Any help will be appreciate,
Thanks in advance,
Bill
Hi Bill, thanks for making an issue!
If you can upload your grid file in a comment, I can have a look at why this is happening and compare it to a grid file that I can make myself.
However, I do believe that this might be an issue with that specific file, I know there is some issues with the first record of that fitacf file (I think the time stamp might be wrong?), and as such this might translate to the grid file when processing.
Either way it would be useful for us to investigate to see if we can get around using the first record of a file to get the correct hemisphere. Can you plot data successfully from the next file (20200101.0200)?
Thanks,
Carley
Thank Carley,
I find when I use different Radar for example Radar zho grid file 20210101.0001.00.zho.grd, it will be plotted successfully. But for Radar jme even I choose next record of fitacf file e.g. 20210101.0400.00.jme.grd, remain same issue with error KeyError: 'vector.mlat',
attached two grd files for your information.
Many thanks,
Bill
Hi Bill, thanks for sending along those files.
I've had a look and the issue is that the files themselves don't have the vector data (there is no data in the file about the positions of the scatter - the vector.mlat/mlon fields - so the plotting function cannot plot anything).
When originally written this field was checked and if it didn't exist you would be shown a 'partial record' error to say that there was no data to plot, however we added another like of code to check the correct hemisphere before this error check so you receive the error above instead of getting the correct error.
I will switch this around and make a pull request to fix the error, however you will not be able to plot most of the records those JME files as they are all partial records with no vectors in still. I hope that clears things up?
Thank you Carley!