Skip to content

Conversation

@maritsandstad
Copy link
Contributor

No description provided.

@maritsandstad
Copy link
Contributor Author

This one is what we ran with to get input-files for NorESM... @ckoven

@glemieux
Copy link
Collaborator

@maritsandstad thanks for the PR. Would you please point me to the spectral grid file (or an example) that you used in your case?

@maritsandstad
Copy link
Contributor Author

So I had to make my own (using ESMF), happy to upload it somewhere.

@glemieux
Copy link
Collaborator

So I had to make my own (using ESMF), happy to upload it somewhere.

Thanks @maritsandstad; I just sent a link to a shared drive to your cicero account.

self.se_regridder = make_se_regridder(regridder_steptwo_weights, regrid_method=regrid_method)
intermediate_ds = ImportRegridTarget(intermediate_regridding_file)
#print(intermediate_ds)
self.step_one_regridder = xe.Regridder(ds_to_regrid, intermediate_ds, regrid_method)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maritsandstad can you describe the workflow for using the intermediate regridding target?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I wasn't able to coax ESMF into making a regridding file directly from 0.5by0.5 degree to the ne30 spectral resolution. Therefore, I needed to regrid from that to the regular grid I was able to get ESMF to make a file for regridding to spectral resolution for (0.9x1.25 degrees), and then I regrid over to the spectral grid from there using my map definition file (which I wasn't allowed to upload so far.) Not ideal, I guess. Do you want me to comment the code better?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation @maritsandstad. Does the interstitial regular grid just need to be a grid close in resolution to the final spectral grid resolution? I'm not familiar with the nomeclature for the spectral grids; what's the 30 in ne30 refer to and what resolution in degrees is it close to?

Code comments are always welcome, but in this case I think it'd be best to add a section to the readme explaining the workflow for the spectral grid option.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it would be good to get an explanation of how to generate the map definition file and what tool you used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also not a resolution expert, but I think ne30 is around 1 degree resolution. I also don't actually know exactly how close the resolution needs to be for ESMF to be able to make a scripgrid file to define the transition. BTW I used ESMF (which is the regridding backend to xesmf) to define the grid file map definition using one of its command line prompts, I'll add the details in the README.

@maritsandstad
Copy link
Contributor Author

So I had to make my own (using ESMF), happy to upload it somewhere.

Thanks @maritsandstad; I just sent a link to a shared drive to your cicero account.

So for some reason I wasn't allowed to upload there... Might be todo with various aliases between email addresses and google accounts...

@glemieux
Copy link
Collaborator

So I had to make my own (using ESMF), happy to upload it somewhere.

Thanks @maritsandstad; I just sent a link to a shared drive to your cicero account.

So for some reason I wasn't allowed to upload there... Might be todo with various aliases between email addresses and google accounts...

Hmm, ok, thanks for trying. I can grab an ne30 surface data set from the e3sm or cesm public input data svn repos and try with that.

Comment on lines +57 to +59
def make_se_regridder(weight_file, regrid_method):
weights = xr.open_dataset(weight_file)
in_shape = weights.src_grid_dims.load().data.tolist()[::-1]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maritsandstad I'm hitting an error here when I try and supply a weight file during the two-step process:

  File "/home/glemieux/Repos/NGEET/Tools/tools-fates-landusedata/src/landusedata/regrid.py", line 59, in make_se_regridder
    in_shape = weights.src_grid_dims.load().data.tolist()[::-1]
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/glemieux/local/miniconda3/envs/landusedata-env/lib/python3.13/site-packages/xarray/core/common.py", line 306, in __getattr__
    raise AttributeError(
        f"{type(self).__name__!r} object has no attribute {name!r}"
    )
AttributeError: 'Dataset' object has no attribute 'src_grid_dims'

I'm using the output from using the -w option from a previous non-two step run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't think that would work, you need a map file that defines both the source grid dimensions and the destination grid, but it might very well be that the code could work with other things than what I used, but then there might have to be some hooks for testing the type of weight-file that's in use... Also, if you can do the transition without the two-step regridding. That would be preferable, but I did not manage to make weight files to make that work...

Adding descriptions on how to generate intermediate regridding file and arguments to use to specify this file when running
@maritsandstad
Copy link
Contributor Author

Have updated README now, hope that clarifies. As for the remapping file, it is 14M, so it might be an option to just upload it to github...? What do you think @glemieux ?

@glemieux
Copy link
Collaborator

glemieux commented Jul 7, 2025

Have updated README now, hope that clarifies. As for the remapping file, it is 14M, so it might be an option to just upload it to github...? What do you think @glemieux ?

That's a good idea @maritsandstad. I've just updated the .gitignore file so you should be able to upload it to tests/resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants