Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing support for lambert azimuthal projection #12

Open
uandrae opened this issue Sep 17, 2024 · 6 comments · Fixed by #16
Open

Missing support for lambert azimuthal projection #12

uandrae opened this issue Sep 17, 2024 · 6 comments · Fixed by #16
Labels
enhancement New feature or request

Comments

@uandrae
Copy link

uandrae commented Sep 17, 2024

Is your feature request related to a problem? Please describe.

In the DE330 DestinE project we output hydrological data in the lambert azimuthal projection. When trying to plot this with earthkit.qickmap it fails as shown below. Is this projection not yet supported?

[snh@ac6-101 ~]$ python3 ./ek.py 
Traceback (most recent call last):
  File "/etc/ecmwf/nfs/dh1_home_b/snh/./ek.py", line 8, in <module>
    qmap.block(data)
  File "/home/snh/.local/lib/python3.10/site-packages/earthkit/plots/quickmap.py", line 9, in wrapper
    getattr(subplot, function.__name__)(*args, **kwargs)
  File "/home/snh/.local/lib/python3.10/site-packages/earthkit/plots/components/subplots.py", line 225, in wrapper
    return self._extract_plottables(
  File "/home/snh/.local/lib/python3.10/site-packages/earthkit/plots/components/subplots.py", line 371, in _extract_plottables
    x_values = source.x_values
  File "/usr/local/apps/python3/3.10.10-01/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/snh/.local/lib/python3.10/site-packages/earthkit/plots/sources/earthkit.py", line 178, in x_values
    return self.extract_x()
  File "/home/snh/.local/lib/python3.10/site-packages/earthkit/plots/sources/earthkit.py", line 143, in extract_x
    return self.extract_xy()[0]
  File "/home/snh/.local/lib/python3.10/site-packages/earthkit/plots/sources/earthkit.py", line 136, in extract_xy
    points = self.data.to_points(flatten=False)
  File "/home/snh/.local/lib/python3.10/site-packages/earthkit/data/core/fieldlist.py", line 386, in to_points
    raise ValueError("to_points(): geographical coordinates in original CRS are not available")
ValueError: to_points(): geographical coordinates in original CRS are not available

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Organisation

DE330@DestinE

@uandrae uandrae added the enhancement New feature or request label Sep 17, 2024
@JamesVarndell JamesVarndell transferred this issue from ecmwf/earthkit Sep 23, 2024
@JamesVarndell
Copy link
Collaborator

JamesVarndell commented Sep 23, 2024

Hi @uandrae, thanks for opening this issue.

Could you please share the code that you ran which triggered this error, and if possible the data that you were trying to plot? The Lambert azimuthal equal area projection is supported in earthkit-plots, but in this case it looks like earthkit is unable to extract that original Lambert gridpoints from your data, so it would be very useful to see the original file you're trying to plot. Many thanks!

@uandrae
Copy link
Author

uandrae commented Sep 23, 2024

Thanks for getting back to me. Data is extracted from MARS as

retrieve,
  class=ce,
  date=2023-08-10,
  expver=1,
  levtype=sfc,
  model=lisflood,
  origin=ecmf,
  param=240023,
  step=6,
  stream=efas,
  time=00:00:00,
  type=fc,
  target="efas_2023 .grib"

using the earthkit plotting

import earthkit.data
import earthkit.maps
infile = "efas_2023.grib"
data = earthkit.data.from_source("file", infile)
earthkit.maps.quickplot(data)

Fails as above. Whereas if I use a date = 2024-08-10 where the data is stored in latlon in MARS the plotting works.

@uandrae
Copy link
Author

uandrae commented Oct 7, 2024

Did you manage to reproduce my error?

@JamesVarndell
Copy link
Collaborator

Hi @uandrae,

Many thanks for sharing your code - I have managed to reproduce the error, and I'm working on a fix which should be released early this week. Thanks for your patience! :)

@JamesVarndell JamesVarndell linked a pull request Oct 7, 2024 that will close this issue
@JamesVarndell
Copy link
Collaborator

Hi @uandrae,

I've released a fix for this at earthkit-plots version 0.2.3 - you should be able to get it with:

pip install earthkit-plots --upgrade

Note also that this issue was migrated from the earthkit-maps project to earthkit-plots; these used to be two separate libraries but for many good reasons (and while earthkit is still in beta) we decided to merge earthkit-maps into earthkit-plots. Apologies for the inconvenience!

If you want to run the equivalent of earthkit.maps.quickplot(data) in earthkit-plots, you'll need to do the following:

import earthkit.plots.quickmap as qmap

qmap.plot(data)

Give that a go and let me know if it works as expected. Many thanks!

@JamesVarndell JamesVarndell reopened this Oct 7, 2024
@uandrae
Copy link
Author

uandrae commented Oct 7, 2024

I'm afraid that

import earthkit.data
import earthkit.plots.quickmap as qmap

infile = "/scratch/snh/txt2nc/efas_2024.grib"
data = earthkit.data.from_source("file", infile)
qmap.plot(data)

just ends without errors, or any generated plots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants