Skip to content

73 water vapor notebook - #74

Open
rogerkuou wants to merge 34 commits into
mainfrom
73_water_vapor_notebook
Open

73 water vapor notebook#74
rogerkuou wants to merge 34 commits into
mainfrom
73_water_vapor_notebook

Conversation

@rogerkuou

@rogerkuou rogerkuou commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Fix #73 .

Should be merged after #96, since PR #96 contains improvement for this PR.

Should be merged after #92
Contains changes in #92 to fix gem embedding bug.
(#92 already merged on Sep 9)

Changes in code
Added check for empty dataset
Init loss in predict as a tensor

Changes in notebooks:
separated notebooks to sst and watervapor folder
added daily watervapor training notebook with local execution results
added hourly watervapor traning notebook with Levante execution results

@rogerkuou

Copy link
Copy Markdown
Collaborator Author

Hi @SarahAlidoost , while working on #73, I got an error in the notebook. This notebooks is adapted from the SST hourly one.

It fails on average_loss.item(), which hints that average_loss is a dictionany. Do you have clue on this? I am running with the CPU mode instead of GPU.

@rogerkuou
rogerkuou marked this pull request as ready for review July 16, 2026 13:52
@rogerkuou

Copy link
Copy Markdown
Collaborator Author

Hi @SarahAlidoost , can you review this notwbook when you have time?

The error was caused by an empty dataset. I added a check to predict, and initiated loss as an zero Tensor.

Another thing maybe we need to pay attention, is the water wapor data is downsampled by the factor of 2 comparing to SST. This requires some attention to lsm data. In the notebook I used an average window to downsample the lsm, and set <0.5 to 0, and >=0.5 to 1. We can discuss if this makes sense.

@SarahAlidoost SarahAlidoost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rogerkuou Thanks! 👍 I added one comment on the changed code. Levante is not available today and I dont have data locally. I will check the notebook later. About the spatial resolution of water vapor, I expected era5 data have the same spatial resolution; this is something to check in our next update meeting. I couldnot also check the era5 data as CDS is also on maintenance.

Comment thread climanet/predict.py Outdated
@SarahAlidoost

Copy link
Copy Markdown
Member

Hi @SarahAlidoost , can you review this notwbook when you have time?

The error was caused by an empty dataset. I added a check to predict, and initiated loss as an zero Tensor.

Another thing maybe we need to pay attention, is the water wapor data is downsampled by the factor of 2 comparing to SST. This requires some attention to lsm data. In the notebook I used an average window to downsample the lsm, and set <0.5 to 0, and >=0.5 to 1. We can discuss if this makes sense.

Indeed there are a few things about water vapor data to check:

  • the spatial resolution of data on levante is 0.5. The water vapor data is available on cds with resolution 0.25
  • data is cut between (-80, 80) in latitude dimension
  • the latitudes are not increasing they are from (80, -80) while longitude are i.e. (-180, 180)

@rogerkuou

rogerkuou commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @SarahAlidoost , can you review this notwbook when you have time?
The error was caused by an empty dataset. I added a check to predict, and initiated loss as an zero Tensor.
Another thing maybe we need to pay attention, is the water wapor data is downsampled by the factor of 2 comparing to SST. This requires some attention to lsm data. In the notebook I used an average window to downsample the lsm, and set <0.5 to 0, and >=0.5 to 1. We can discuss if this makes sense.

Indeed there are a few things about water vapor data to check:

  • the spatial resolution of data on levante is 0.5. The water vapor data is available on cds with resolution 0.25
  • data is cut between (-80, 80) in latitude dimension
  • the latitudes are not increasing they are from (80, -80) while longitude are i.e. (-180, 180)

During the meeting in July 24, we discussed the issues with Axel:

  • The resolution is coming from the fact the satellite observations on water vapor has resolution with 0.5 degress. Hence it does not add value to go to -.25 degree resolution
  • The data cut and lat coordinate order comes from how regredding is set. Axel is working on generating a new version of dataset with (-90, 90) and ascending ordering.

@SarahAlidoost shall we consider merging this PR for now? My motivation is that this PR also renames example notebooks to distinguish sst and water vapor. It can set good templates for other PRs.

@rogerkuou

rogerkuou commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

Updated on 20260814
Ihave confirmed with Axel that the satellite data's coverage is (-80, 80), and the resolution is 0.5 deg. Axel prefers not to create a new set of data, but use the current version. This means for the order of lat we can flip it by ourselves.

About the masking, I found CDS always provide 0.25 degrees. If using esemble mean to download, the downloaded mask are floating values. I check with xel he is fine with thresholding the floating mask with 0.5 values. Maybe let's do that and create another mask file matching the Water vapor data?

What do you think @SarahAlidoost and @meiertgrootes ?

@rogerkuou
rogerkuou marked this pull request as draft September 7, 2026 13:25
@rogerkuou
rogerkuou marked this pull request as ready for review September 8, 2026 11:28
@rogerkuou

rogerkuou commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @SarahAlidoost, in this PR I made example notebooks for watervapor. I executed the daily one locally and the hourly one on Levante.

I observed that the validation loss does not reduce, and the training stops with early stops. This is especially significant in the hourly training. I have tried using different month (I started with Jan, then switched to April. It the same as SST setting, three identical month from 2020-2022 for training, validation and testing), and reduced the learning rate to half (just in case if we are missing optimal). The validation loss curve stays flat. I hope for a full training with multiple month can help. But I will wait till your test with #92

(Updated on SEP 10)
Reagrding the small trial of validate/test only on training data, see this GH Gist. It should the traning loss continue to drop, and the prediction results are significantly improved comparing to baseline.
The "artificial oscillation" in the daily notebook is caused by an uncleared training history, where at same epoch there are multiple loss. To avoid conflicts, I solved this in #95. By removing caches and re-run we do not have this anymore. See the updated notebook.

I merged your fix in #92 to this PR, to include your fix for the bug. So it will make sense to review this after merging #92.

@rogerkuou

Copy link
Copy Markdown
Collaborator Author

Hi @SarahAlidoost , I brought this branch up to date. See my previous comment for details.

Meanwhile, following our discussion today, I will make another test on the training dataset to see if the training is able to overfit on the training data. This can validate if the problem is actually training on one month

Comment on lines +53 to +57
<<<<<<< HEAD:notebooks/sst/training_hourly_sst.ipynb
"monthly_data_test = xr.open_mfdataset(data_folder / f\"202001_mon_ERA5dc_full_{var_name}.nc\")\n",
=======
"monthly_data_test = xr.open_mfdataset(data_folder / f\"202201_mon_ERA5dc_full_{var_name}.nc\")\n",
>>>>>>> main:notebooks/example_hourly.ipynb

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these are leftover from merging. Could you fix them?

Comment on lines +483 to +487
<<<<<<< HEAD:notebooks/sst/training_hourly_sst.ipynb
"spatial_patch_size = monthly_da.shape[1:] # the whole dataset \n",
=======
"spatial_crop_size = monthly_da.shape[1:] # the whole dataset \n",
>>>>>>> main:notebooks/example_hourly.ipynb

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here.

Comment thread scripts/tuning.py
Comment on lines +88 to +89
"max_concurrent_trials": args.num_nodes
* 2, # less than GPUs per node (4) avoid OOM

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"max_concurrent_trials": args.num_nodes
* 2, # less than GPUs per node (4) avoid OOM
"max_concurrent_trials": args.num_nodes * 2, # less than GPUs per node (4) avoid OOM

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.

Add a example notebook for water vapor

2 participants