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

Satellite normalisation #97

Merged
merged 24 commits into from
Jan 3, 2025
Merged

Satellite normalisation #97

merged 24 commits into from
Jan 3, 2025

Conversation

felix-e-h-p
Copy link
Contributor

Normalisation introduced for satellite data utilising 2020 values for std and mean

Not entirely sure epsilon factor is truly necessary - yet left in as a safe guarding mechanism

@felix-e-h-p felix-e-h-p linked an issue Dec 20, 2024 that may be closed by this pull request
@peterdudfield peterdudfield reopened this Dec 20, 2024
@peterdudfield
Copy link
Contributor

I just re opened it to try and trigger the tests, but weirdly they dont seem to be running

requirements.txt Outdated Show resolved Hide resolved
Copy link
Member

@dfulu dfulu left a comment

Choose a reason for hiding this comment

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

Thanks for doing this @felix-e-h-p! It looks good, but I think there are a few things that we should clean up first

ocf_data_sampler/torch_datasets/process_and_combine.py Outdated Show resolved Hide resolved
tests/.DS_Store Outdated Show resolved Hide resolved
tests/torch_datasets/.DS_Store Outdated Show resolved Hide resolved
.github/workflows/workflows.yaml Outdated Show resolved Hide resolved
ocf_data_sampler/.DS_Store Outdated Show resolved Hide resolved
ocf_data_sampler/numpy_batch/nwp.py Outdated Show resolved Hide resolved
ocf_data_sampler/numpy_batch/satellite.py Outdated Show resolved Hide resolved
return xr.DataArray(
data,
coords=coords,
dims=["init_time_utc", "step", "y_osgb", "x_osgb"],
Copy link
Member

Choose a reason for hiding this comment

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

This is strictly not the data format that process_and_combine_datasets() expects. It expects that the NWP data will have been passed through the select_time_slice_nwp() function function which changes the dimensions from ["init_time_utc", "step", "channel", "x", "y"] to ["target_time_utc", "channel", "x", y"].

Although admittedly the process_and_combine_datasets() doesn't really check this since it is only ever supposed to be used as part of the pipeline where select_time_slice_nwp() has been 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.

Updated the test to ensure that NWP data is passed through the select_time_slice_nwp function initially before process and combine is called - would appreciate your feedback on this section if all OK

Copy link
Member

Choose a reason for hiding this comment

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

For now I think I'd bypass the select_time_slice_nwp() function here and just update this fixture. It means this test is independent of errors in select_time_slice_nwp().

something like:

    data = np.random.rand(3, 3, 4, 4)
    coords = {
        "target_time_utc": pd.date_range("2023-01-01 12:00", freq="1h", periods=3),
        "channel": ["t", "dswrf", "lcc"],
        "x_osgb": np.arange(4),
        "y_osgb": np.arange(4),
    }
    xr.DataArray(
        data,
        coords=coords,
        dims=["target_time_utc", "channel", "y_osgb", "x_osgb"],
    )

numpy_modalities.append(convert_satellite_to_numpy_batch(da_sat))
sat_numpy_modalities = convert_satellite_to_numpy_batch(da_sat)
# Combine the Satellite into NumpyBatch
numpy_modalities.append({SatelliteBatchKey.satellite_actual: sat_numpy_modalities})
Copy link
Contributor

Choose a reason for hiding this comment

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

This line, could be changed to back to numpy_modalities.append(convert_satellite_to_numpy_batch(da_sat), and then I think itll be fine

@peterdudfield
Copy link
Contributor

Would you be able to pull main into this branch, and then add sat normalization to here too - https://github.com/openclimatefix/ocf-data-sampler/blob/main/ocf_data_sampler/torch_datasets/process_and_combine.py#L122

Copy link

codecov bot commented Dec 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.72%. Comparing base (f9fd827) to head (94c9caf).
Report is 31 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #97      +/-   ##
==========================================
- Coverage   95.44%   94.72%   -0.73%     
==========================================
  Files          37       39       +2     
  Lines         989     1061      +72     
==========================================
+ Hits          944     1005      +61     
- Misses         45       56      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@felix-e-h-p felix-e-h-p merged commit 522f8e3 into main Jan 3, 2025
6 checks passed
@felix-e-h-p felix-e-h-p deleted the satellite-normalisation branch January 3, 2025 09:25
@peterdudfield
Copy link
Contributor

@all-contributors please add @felix-e-h-p for code

Copy link
Contributor

@peterdudfield

I've put up a pull request to add @felix-e-h-p! 🎉

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.

Satellite normalization
3 participants