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

_wrfchem_mm.py WRF-Chem read issue #149

Closed
dwfncar opened this issue Dec 6, 2022 · 3 comments
Closed

_wrfchem_mm.py WRF-Chem read issue #149

dwfncar opened this issue Dec 6, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@dwfncar
Copy link
Collaborator

dwfncar commented Dec 6, 2022

With leaving the line 192, “dset = dset.reset_index(["XTIME", "datetime"], drop=True)”, of monetio/models/_wrfchem_mm.py on, it will complain messages below when I read the sample wrf-chem data on Cheyenne.

“Traceback (most recent call last):

  File "/glade/work/swei/Git/mmm/read_fcst.py", line 28, in <module>

    an.open_models()

  File "/glade/work/swei/Git/MELODIES-MONET/melodies_monet/driver.py", line 525, in open_models

    m.open_model_files()

  File "/glade/work/swei/Git/MELODIES-MONET/melodies_monet/driver.py", line 322, in open_model_files

    self.obj = mio.models._wrfchem_mm.open_mfdataset(self.files,**self.mod_kwargs)

  File "/glade/work/swei/Git/monetio/monetio/models/_wrfchem_mm.py", line 192, in open_mfdataset

    dset = dset.reset_index(["XTIME", "datetime"], drop=True)

  File "/glade/work/swei/conda-envs/melodies-monet/lib/python3.9/site-packages/xarray/core/dataset.py", line 4183, in reset_index

    raise ValueError(

ValueError: ('datetime', 'XTIME') are not coordinates with an index”
@dwfncar dwfncar added the bug Something isn't working label Dec 6, 2022
@rschwant
Copy link
Collaborator

rschwant commented Dec 7, 2022

It looks like this line of code worked with older versions of xarray and then with more recent updates it stopped working. On xarray's website it says reset_index is legacy code from pandas, so we should probably move away from it.

I think all that has to happen to get this working again with both older and newer versions of xarray is to replace this:
dset = dset.reset_index(["XTIME", "datetime"], drop=True)

With this instead:
dset = dset.reset_coords(["XTIME", "datetime"], drop=True)

The overall goal was just to remove XTIME and datetime as coordinates and it seems like the second option does this equally well and is the preferred method. I'm at a conference, but @zmoon I may be able to test this more tomorrow or if you agree with this change and just want to update this in MONETIO feel free.

@rschwant
Copy link
Collaborator

This is fixed on the develop branch of MONETIO now (noaa-oar-arl/monetio#95). I will close this once this fix is pushed to the stable branch of MONETIO.

@rschwant
Copy link
Collaborator

This is updated in the stable branch of MONETIO now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants