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

EXF not reading/interpolating input as expected #34

Closed
DaniJonesOcean opened this issue Feb 2, 2023 · 5 comments
Closed

EXF not reading/interpolating input as expected #34

DaniJonesOcean opened this issue Feb 2, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@DaniJonesOcean
Copy link
Contributor

Problem statement and example

I'm attempting to force SO-WISE with a subset of the ERA5 dataset. However, the output of EXF is incorrect. For example, let's look at the 2m air temperature as represented in this binary file ERA5_sowise_tmp2m_degK_issue01_1992. In Matlab, we can view it using:

fid=fopen('ERA5_sowise_tmp2m_degK_issue01_1992','r','ieee-be');
A=fread(fid,'float32');
A3D = reshape(A,[725 249 1464]);
pcolor(A3D(:,:,1)),shading flat,colorbar

which produces the following, presented without any rotation or coordinates, on the ERA5 grid:
tmp2m

That is an example of the kind of field that is given to MITgcm via the `EXF package. However, EXF is not reading and interpolating this field as expected. Here is a snapshot of 2m air temperature from the MITgcm diagnostics package after a single timestep:

atmp_from_exf

It looks like a single longitudinally-varying profile is repeated at each latitude.

Second example: v wind

The issue appears in each of the forcing fields, so it's not just an issue with one file. As a second example, consider the meridional winds from ERA5. In Matlab, we can view it using:

fid=fopen('ERA5_sowise_v10m_issue01_1992','r','ieee-be');
A=fread(fid,'float32');
A3D=reshape(A,[725 249 1464]);
pcolor(A3D(:,:,1)),shading flat,colorbar

which produces the following:
vwind_binary

But the output from EXF, via a snapshot from the diagnostics package, appears as follows:
vwind_from_exf

Note that both the pattern and the values are wrong.

Things I've checked

As part of my troubleshooting, I've confirmed the following:

  • EXF is expecting a single-precision real number (i.e. exf_iprec = 32 and exf_yftype = RL in data.exf
  • The binary files are oriented in the way that MITgcm expects (as confirmed by comparison with a SOSE input field)
  • The input field grid parameters are correct in data.exf
  • Updated to the latest version of MITgcm and recompiled
  • I used a byteswap IO flag at compile time, so I think the endian-ness should be consistent throughout

Ideal behavior

Ideally, EXF would read in the binary file on the ERA5 grid and interpolate onto the SO-WISE grid

More context

Some additional context/details that may be helpful:

Thanks in advance for any help or insight you can provide 🌊

@DaniJonesOcean DaniJonesOcean added the bug Something isn't working label Feb 2, 2023
@DaniJonesOcean DaniJonesOcean self-assigned this Feb 2, 2023
@DaniJonesOcean
Copy link
Contributor Author

I regridded ERA5 onto the SO-WISE grid, so we are no longer using the on-the-fly EXF interpolation at runtime. Unfortunately, that did absolutely nothing. We still have almost exactly the same problem

@DaniJonesOcean
Copy link
Contributor Author

I have tried every permutation of indices, i.e. (x,y,t), (y,x,t), (t,x,y), and (t,y,x), and none of them worked. Regardless of the order of indices, the diagnostic output from EXF still looks like this:

ugh

@DaniJonesOcean
Copy link
Contributor Author

Note that, having switched to a python-based regridding scheme xESMF, I now use this command for creating the binary files:

var_out.astype('>f4').tofile(os.path.join(fout, filename.replace('.nc', '')))

@DaniJonesOcean
Copy link
Contributor Author

Fixed! I pushed it to main...because I live dangerously 😎

It had to do with how the grid is specified in data.exf. You have to specify:

field_lat_inc = Ny*0.25

where Ny is the number of latitude points in the forcing dataset.

More detail in this thread:
http://mailman.mitgcm.org/pipermail/mitgcm-support/2023-February/013342.html

@DaniJonesOcean
Copy link
Contributor Author

yay

How lovely. Closing 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

1 participant