google-deepmind / graphcast

Apache License 2.0
4.37k stars 538 forks source link

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

Closed qwer9872 closed 5 months ago

qwer9872 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

@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 commented 7 months ago

@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 commented 6 months ago

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 commented 5 months ago

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