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

Ask for your help: Crop my personal area of interest, but no results. #29

Closed
qwer9872 opened this issue Nov 30, 2023 · 6 comments
Closed

Comments

@qwer9872
Copy link

Dear graphcast experts, I uploaded my own research area: shp file into your demo code and then cropped the example_batch data. The final output includes only Targets Predictions and no results for predictions and Diff. I looked at the specific Predictions and the latitude and longitude ranges are correct, the geographical ranges are correct, but the variables will all have values of nan. I beg your answer. Thank you very much.
Here are my cut code:

SHP = geopandas. Read_file ('/content/drive/MyDrive/graphcast - the main/SHP/roi. SHP ')
example_batch.rio.set_spatial_dims(x_dim="lon", y_dim="lat", inplace=True)
example_batch.rio.write_crs("WGS1984", inplace=True)
example_batch = example_batch.rio.clip(shp.geometry.apply(mapping),shp.crs)

1701334975102

@Aquila96
Copy link

Aquila96 commented Dec 7, 2023

It's not very clear in your description and code as to how you produced the forecast, I assumed that you have largely followed the processes laid out in the jupyter.

One of the reasons that you could be getting an all np.nan result is that some of your forcing_variables are not filled in correctly, most likely toa_incident_solar_radiation, that is, all of the target timesteps' toa_incident_solar_radiation must be supplied.

@qwer9872
Copy link
Author

qwer9872 commented Dec 7, 2023

@Aquila96 Thank you very much for your answer. Your demo data is complete global data, I added my code after your "Load weather data" section, my purpose is to only input my interest area and predict the result of this area, but the final result is nan.If it is wrong according to what you said, how should I correct it? Thank you very much for your reply.
@Aquila96

with gcs_bucket.blob(f"dataset/{dataset_file.value}").open("rb") as f:
  example_batch = xarray.load_dataset(f).compute()
SHP = geopandas. Read_file ('/content/drive/MyDrive/graphcast - the main/SHP/roi. SHP ')
example_batch.rio.set_spatial_dims(x_dim="lon", y_dim="lat", inplace=True)
example_batch.rio.write_crs("WGS1984", inplace=True)
example_batch = example_batch.rio.clip(shp.geometry.apply(mapping),shp.crs)

@Aquila96
Copy link

Aquila96 commented Dec 7, 2023

@Aquila96 Thank you very much for your answer. Your demo data is complete global data, I added my code after your "Load weather data" section, my purpose is to only input my interest area and predict the result of this area, but the final result is nan.If it is wrong according to what you said, how should I correct it? Thank you very much for your reply. @Aquila96

with gcs_bucket.blob(f"dataset/{dataset_file.value}").open("rb") as f:
  example_batch = xarray.load_dataset(f).compute()
SHP = geopandas. Read_file ('/content/drive/MyDrive/graphcast - the main/SHP/roi. SHP ')
example_batch.rio.set_spatial_dims(x_dim="lon", y_dim="lat", inplace=True)
example_batch.rio.write_crs("WGS1984", inplace=True)
example_batch = example_batch.rio.clip(shp.geometry.apply(mapping),shp.crs)

I'm not familiar with rioxarray but it appears that the you have not supplied new data but simply clipped the example_batch (rio.clip()) to be the area you wanted (following the shp file). This will introduce np.nan values in the input (blank areas in your leftmost plot), the behaviour of GraphCast is that it does not like np.nan values anywhere in its forcing and input terms, so an all nan output is to be expected.

The model is designed to accept strictly global initial conditions with pre-defined grid sizes, inputs not following the prescribed data formulations would generate np.nan or inaccurate results.

@tewalds
Copy link
Member

tewalds commented Dec 20, 2023

I don't quite follow what you're trying to do, but graphcast only works on the whole world, not on patches of any type. If you try to make predictions where some of the inputs are nonsensical (eg all zeros, or nans), you will get nonsense outputs (eg all nans) which may well be rendered as all white.

@mjwillson
Copy link
Collaborator

I think Timo's reply above pretty much summarises it, closing.

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

No branches or pull requests

5 participants
@mjwillson @tewalds @Aquila96 @qwer9872 and others