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

Linear blending #229

Merged
merged 8 commits into from
Nov 3, 2021
Merged

Conversation

wdewettin
Copy link

This addresses issue #226. I added a nowcasting method called linear blending. This works for all nowcast methods (deterministic and ensemble) and is also compatible with NWP ensembles. Furthermore, I added an example which uses some dummy NWP data to blend with and which plots the results. Lastly, I also added a test for the linear blending function.

wdewettin and others added 3 commits August 5, 2021 14:03
Added linear blending function, example file and test
The replacement is done at the end
@RubenImhoff RubenImhoff self-requested a review August 9, 2021 12:55
@RubenImhoff RubenImhoff added the enhancement New feature or request label Aug 9, 2021
@RubenImhoff RubenImhoff added this to In progress in pysteps-v2 via automation Aug 9, 2021
@RubenImhoff RubenImhoff linked an issue Aug 9, 2021 that may be closed by this pull request
@RubenImhoff
Copy link
Contributor

Great work, @wdewettin! I was (actually, we were - that is including @wdewettin and @ladc) wondering whether we should place this method in a/the blending folder or whether it fits in the nowcasts folder as currently done by @wdewettin. Any thoughts?

Copy link
Contributor

@RubenImhoff RubenImhoff left a comment

Choose a reason for hiding this comment

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

Great, @wdewettin! I left some comments and questions. Some of them I could implement myself as well. Let's just wait for the comments of the others (and feel free to comment yourself on them), then we'll continue with the final changes.
Exciting to have this option in pysteps soon!

containing the NWP precipitation fields ordered by timestamp from oldest
to newest. The time steps between the inputs are assumed to be regular
(and identical to the time step between the nowcasts). If no NWP
data is given the value of R_nwp is None and no blending will be performed.
Copy link
Contributor

Choose a reason for hiding this comment

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

In case of R_nwp = None, the script is similar to steps.py, right? Do we want to use the script as a postprocessing tool, i.e. the user makes a nowcast with steps.py and passes the output on to linear_blending.py, or do we want to keep it this way and have some duplicate code with steps.py? As steps.py may also change to allow for other blending methods, I wonder what everyone thinks about the best way forward.

Copy link
Member

Choose a reason for hiding this comment

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

Here the object returned should be equal to the output of the nowcasting method used if R_nwp=None.
I understand that if we are going to create a function the ingest both sources of precipitation, then few lines of code must be duplicated. Perhaps in the future a higher level blending script should be created in the way that accept multiple sources of precipitation, and weights for each source (or a method to determine those weigths) and return blended fields. This approach may be easier to maintain, but perhaps harder to understand by users.

)

# Transform the precipitation back to mm/h
R_nowcast = transformation.dB_transform(R_nowcast, threshold=-10.0, inverse=True)[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the threshold is present in the metadata (the transformer at least returns the metadata). We could add this to the function, then we don't have to hard code it here.

Copy link
Member

Choose a reason for hiding this comment

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

I understand why this is done here, but this is assuming that R_nwp is in mm/hr and that the precip is in dB. If this is the case, then we need to indicate those limitations in the descrition of the function. Alternatively, both sources should be in mm/hr and the conversion of precip to dB be done within this function as well.

Copy link
Member

Choose a reason for hiding this comment

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

I understand why this is done here, but this is assuming that R_nwp is in mm/hr and that the precip is in dB. If this is the case, then we need to indicate those limitations in the description of the function. Alternatively, both sources could be in mm/hr and the conversion of precip to dB be done within this function as well.

Said that the returned output R_blended will be always in mm/hr

R_nowcast[np.newaxis, :, :], n_ens_members_max, axis=0
)
else:
repeats = [
Copy link
Contributor

Choose a reason for hiding this comment

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

After consulting @wdewettin and @ladc, I figured out what this piece of code does. So if you e.g. have 10 ensemble nowcasts members and 3 NWP members, the output will be an ensemble of 10 members. Hence, the three NWP members are blended with the first three members of the nowcast (member one with member one, two with two, etc.), subsequently, the same NWP members are blended with the next three members (NWP member one with member 4, NWP member 2 with member 5, etc.), until 10 is reached.

Is this the way to go (works for me) or do we want an output of 30 (10 x 3 members here) in this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh and @wdewettin, let's add some comments to the code here so that this procedure is clear. :) (B.t.w., I can add that too, but I'll wait for the responses - and thus possible changes - of the others)

Copy link
Author

Choose a reason for hiding this comment

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

Yes! I will await the responses from the others, and then add some comments

Copy link
Member

Choose a reason for hiding this comment

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

I agree. It wuld be nice to add additional comments in this part of the script as @RubenImhoff suggested.

Copy link
Member

Choose a reason for hiding this comment

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

I agree. It would be nice to add additional comments in this part of the script as @RubenImhoff suggested.

-------
R_blended: ndarray
Array of shape (timesteps, m, n) in the case of no ensemble or
of shape (n_ens_members, timesteps, m, n) in the case of an ensemble
Copy link
Contributor

Choose a reason for hiding this comment

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

With the way it is implemented at this moment: n_ens_members equals the maximum number of ensemble members in the input, so either the number of the nowcast or that of the NWP. Perhaps good to add that here.

Copy link
Contributor

Choose a reason for hiding this comment

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

(B.t.w., I can add that too, but I'll wait for the responses - and thus possible changes - of the others)

pysteps/nowcasts/linear_blending.py Outdated Show resolved Hide resolved
R, metadata = transformation.dB_transform(R, metadata, threshold=0.1, zerovalue=-15.0)

# Set missing values with the fill value
# R[~np.isfinite(R)] = -15.0
Copy link
Contributor

Choose a reason for hiding this comment

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

If not used, we could remove these lines.

Copy link
Author

Choose a reason for hiding this comment

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

True, in the plot_steps_nowcast.py example, this is how the missing data was handled, but here we use the (dummy) NWP data

R, metadata = dimension.aggregate_fields_space(R, metadata, 2000)

# Import the dummy NWP data (vertical line moving to the left)
R_nwp = dummy_nwp(R[-1, :, :], n_leadtimes + 1, max=7, mean=4, speed=0.2 * 350)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps plot the radar rainfall and NWP rainfall forecast field somewhere, to give the reader (as this example may end up in the pysteps gallery) and idea of what the example fields look like.

Copy link
Author

Choose a reason for hiding this comment

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

Do you mean plotting them for every timestep? Or only the first one(s)?

Copy link
Contributor

Choose a reason for hiding this comment

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

First ones should be fine. :)

@dnerini
Copy link
Member

dnerini commented Aug 11, 2021

Great work, @wdewettin! I was (actually, we were - that is including @wdewettin and @ladc) wondering whether we should place this method in a/the blending folder or whether it fits in the nowcasts folder as currently done by @wdewettin. Any thoughts?

Because of the way linear blending works, I personally think it could be provided as a simple postprocessing method (therefore within the postprocessing module) that takes as inputs two separate nowcasts and the relatives weights.

This said, I like the way @wdewettin implemented it, where one has to specify the the nowcasting method and pass the corresponding NWP forecast. But because of this dependency on the actual nowcasting methods, it could make more sense to move into a new blending module. We could say that as a general (and not necessarily very strict) rule, the methods included in a module should be independent one to the other. In this sense, the nowcating module should only include alternative nowcasting methods.

@dnerini
Copy link
Member

dnerini commented Aug 11, 2021

Very nice contribution @wdewettin ! I highly appreciate the fact that you already included all the documentation (including a gallery example!) and tests, well done!

I plan to go through your PR in detail as soon as possible. For now, I have a more general request. Would it be possible to make your method work with an xarray DataArray object instead of numpy arrays?

@wdewettin wdewettin closed this Aug 11, 2021
pysteps-v2 automation moved this from In progress to Done Aug 11, 2021
@wdewettin wdewettin reopened this Aug 11, 2021
pysteps-v2 automation moved this from Done to In progress Aug 11, 2021
@wdewettin
Copy link
Author

Yes, @dnerini, I will take a look at making my method work with xarrays!

@wdewettin
Copy link
Author

@dnerini Sorry for my late response! I looked into making it work with xarrays instead of numpy arrays and I found that it would be better to wait with that for the time being. All the functions on which the linear blending function is based still output numpy arrays, and it will be a lot easier to make the linear blending function work with xarrays if those functions are changed first.

Add use_nwp as parameter

Add commentary about use_nwp

Add fill_nwp as parameter
@codecov
Copy link

codecov bot commented Aug 26, 2021

Codecov Report

❗ No coverage uploaded for pull request base (pysteps-v2@3802f8d). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff              @@
##             pysteps-v2     #229   +/-   ##
=============================================
  Coverage              ?   73.83%           
=============================================
  Files                 ?      152           
  Lines                 ?    11213           
  Branches              ?        0           
=============================================
  Hits                  ?     8279           
  Misses                ?     2934           
  Partials              ?        0           
Flag Coverage Δ
unit_tests 73.83% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3802f8d...758f88b. Read the comment docs.

pysteps.nowcasts.linear_blending
================================

Implementation of the linear blending between nowcast and NWP data.
Copy link
Member

Choose a reason for hiding this comment

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

@RubenImhoff @wdewettin thanks for implementing this module.

containing the NWP precipitation fields ordered by timestamp from oldest
to newest. The time steps between the inputs are assumed to be regular
(and identical to the time step between the nowcasts). If no NWP
data is given the value of R_nwp is None and no blending will be performed.
Copy link
Member

Choose a reason for hiding this comment

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

Here the object returned should be equal to the output of the nowcasting method used if R_nwp=None.
I understand that if we are going to create a function the ingest both sources of precipitation, then few lines of code must be duplicated. Perhaps in the future a higher level blending script should be created in the way that accept multiple sources of precipitation, and weights for each source (or a method to determine those weigths) and return blended fields. This approach may be easier to maintain, but perhaps harder to understand by users.

)

# Transform the precipitation back to mm/h
R_nowcast = transformation.dB_transform(R_nowcast, threshold=-10.0, inverse=True)[0]
Copy link
Member

Choose a reason for hiding this comment

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

I understand why this is done here, but this is assuming that R_nwp is in mm/hr and that the precip is in dB. If this is the case, then we need to indicate those limitations in the descrition of the function. Alternatively, both sources should be in mm/hr and the conversion of precip to dB be done within this function as well.

pysteps.nowcasts.linear_blending
================================

Implementation of the linear blending between nowcast and NWP data.
Copy link
Member

Choose a reason for hiding this comment

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

Great job @wdewettin and @RubenImhoff

R_nowcast[np.newaxis, :, :], n_ens_members_max, axis=0
)
else:
repeats = [
Copy link
Member

Choose a reason for hiding this comment

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

I agree. It wuld be nice to add additional comments in this part of the script as @RubenImhoff suggested.

R_nowcast[np.newaxis, :, :], n_ens_members_max, axis=0
)
else:
repeats = [
Copy link
Member

Choose a reason for hiding this comment

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

I agree. It would be nice to add additional comments in this part of the script as @RubenImhoff suggested.

)

# Transform the precipitation back to mm/h
R_nowcast = transformation.dB_transform(R_nowcast, threshold=-10.0, inverse=True)[0]
Copy link
Member

Choose a reason for hiding this comment

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

I understand why this is done here, but this is assuming that R_nwp is in mm/hr and that the precip is in dB. If this is the case, then we need to indicate those limitations in the description of the function. Alternatively, both sources could be in mm/hr and the conversion of precip to dB be done within this function as well.

Said that the returned output R_blended will be always in mm/hr

@cvelascof
Copy link
Member

@RubenImhoff @wdewettin @dnerini apologies for the mess in my comments ... not sure what did it go wrong?

@RubenImhoff
Copy link
Contributor

All requested changes implemented. Main task left is to make the code xarray ready for pysteps-v2. As discussed before, we may also do that in a separate PR.

@RubenImhoff RubenImhoff merged commit d30b07e into pySTEPS:pysteps-v2 Nov 3, 2021
pysteps-v2 automation moved this from In progress to Done Nov 3, 2021
dnerini added a commit that referenced this pull request Jan 14, 2022
* First basic functions to implement STEPS blending

* Add compute of blend means,sigmas and recompose

* pysteps.io with xarray (#219)

* Add xarray dependency

* MCH importer returns an xarray Dataset

* Remove plot lines

* Remove import

* Adapt readers to xarray format

* Rewrite as more general decorator

* Add missing metadata

* Adapt io tests

* Mrms bounding box (#222)

* Fix bounding box coordinates

* Add missing metadata

* Import xarray DataArray

Ignore quality field

* Black

* Do not hardcode metadata

* Address review comments by ruben

* Add a legacy option to the io functions

A "legacy" options is added to revert back the importers and readers behavior to version 1. This is a temporary solution to allow the examples, and other functions, to run as usual (v1.*).

Hopefully, this is will allow a easier transition into version 2 during the development process and will allow testing functions that were not updated to v2.

* Fix compatibility problems with tests

Many of the tests were updated to use the legacy data structures (v1). The tests that still contains issues, were tagged with a TODO message and they are skipped.

This will allow incremental changes to be tested in the new v2.

IMPORTANT: once the v2 branch is stable, we may remove the legacy compatibility from the code base and the tests.

* Update dependencies

* Ignore plugins test

Co-authored-by: Andres Perez Hortal <16256571+aperezhortal@users.noreply.github.com>

* Add blend_optical_flow

* changes to steps blending procedure - weights according to adjusted BPS2006 method

* changes to blending procedures - adjust weights from original BPS2006 method

* Determine spatial correlation of NWP model forecast

* First attempt to make correlations and thus weights lead time dependent (in progress..)

* Change back to original BPS2006 blending formulation and add regression of skill values to climatological values for weights determination

* Reformat code with Black

* Skill score script imports climatological correlation-values from file now

* Small changes to skill score script

* Add skill score tests and an interface

* Add skill score tests and an interface

* Small change to docstring

* Bom import xarray (#228)

* Add import_bom_rf3  using xarray

* Add tests to xarray version

* Fix mrms importer tests

* Pass **kwargs to internal functions

* Add nwp_importers to read bom nwp sample data

* Add bom nwp data to source file

* Add tests for bom_nwp reader

* Fix pystepsrc

Co-authored-by: Andres Perez Hortal <16256571+aperezhortal@users.noreply.github.com>

* Functions to store and compute climatological weights (#231)

* Implement the functions get_default_weights, save_weights, calc_clim_weights. 

These functions are used to evolve the weights in the scale- and skill-dependent blending with NWP in the STEPS blending algorithm. The current weights, based on the correlations per cascade level, are regressed towards these climatological weights in the course of the forecast.

These functions save the current and compute the climatological weights (a running mean of the weights of the past n days, where typically n=30). First daily averages are stored and these are then averaged over the running window of n days.

* Add tests for pysteps climatological weight io and calculations.

* Add path_workdir to outputs section in pystepsrc file and use it as a default path to store/retrieve blending weights.

* Minor changes to docstrings, changes to skill scores and testing scripts

* Completed documentation for blending clim module, cleanup.

Co-authored-by: RubenImhoff <r.o.imhoff@live.nl>

* Main blending module, first steps

* Add simple tests

* Minor changes to tester: velocity now based on rainfall field of NWP

* Add utilities to decompose, store and load NWP cascades for use in blending  (#232)

* First version of NWP decomposition

* Added saving to netCDF

* Completed functions for saving and loading decomposed NWP data

* Added example files for the decomposed NWP functions

* Added compatibility with numpy datetime

* Use default output path_workdir for tmp files in blending/utils.py.

* Update documentation of NWP decomposition functions in utils.py

Co-authored-by: Wout Dewettinck <wout.dewettinck@ugent.be>
Co-authored-by: wdewettin <87696913+wdewettin@users.noreply.github.com>

* Add importer for RMI NWP data (#234)

Add importer for netcdf NWP data from RMI using xarrays.

* Add test for RMI NWP data importer.

* Add entry for RMI NWP data in pystepsrc.

* Run black on everything: fix formatting.

* Add KNMI Harmonie NWP netcdf importer and tests (#235)

* Changes to v_models to make use of multiple timesteps. Changes in the velocity field over time in the NWP forecast will be taken into account now.

* Fixes for KNMI importer:

Add forgotten @postprocess_import()
Don't call dropna on NWP data.

* Avoid shadowing of pysteps.blending.utils by pysteps.utils

* First attempt for probability matching and masking utility; part 1

* Changes to prob matching and masking methods; part 2

* Prob matching and masking changes; part 3. Ready for testing with real data from here on

* Remove unnecessary print statements

* Cleanup imports

* More cleanup

* Update docstrings

* RMI importer for gallery example (will follow)

* Reprojection functionality (#236)

* Added Lesley's reprojection module to this branch

* Added compatibility for three-dimensional xarrays

* Add commentary to reprojection util

* Changes to make reprojection of KNMI data possible

* Changes after Daniele's review

* Add dependencies

* Changes to importers, see issue #215

* Add tests

* Fix some issues

* documentation

* Fixes for tests

* Set requirements again

* Some fixes

* Changes to nwp_importers after Carlos' response

* Remove wrong example script

* Remove rasterio dependencies from lists

* First try to prevent testing error

* Changes Daniele and fix knmi nwp importer

* Add rasterio to tox.ini

* Aesthetics

* rasterio import test

* Add rasterio to the test dependencies

* Reset try-except functionality for rasterio import

* Fix for failing test on windows python 3.6

* add importerskip rasterio

Co-authored-by: Wout Dewettinck <wout.dewettinck@ugent.be>

* Fixes in nwp importers

* Revert "Merge branch 'steps_blending' into pysteps-v2" (#239)

This reverts commit 2c639f8, reversing
changes made to bccb8fc.

* Merge latest version pysteps-v2 into steps_blending branch (#237)

* Update docstrings

* More cleanup

* Cleanup imports

* Cleanup imports

* More cleanup

* Update docstrings

* Update references

Mention the work of Ravuri et al (2021, Nature) as an example of work using cGANs to generate ensembles

* Clean up page

* Reprojection functionality (#236)

* Added Lesley's reprojection module to this branch

* Added compatibility for three-dimensional xarrays

* Add commentary to reprojection util

* Changes to make reprojection of KNMI data possible

* Changes after Daniele's review

* Add dependencies

* Changes to importers, see issue #215

* Add tests

* Fix some issues

* documentation

* Fixes for tests

* Set requirements again

* Some fixes

* Changes to nwp_importers after Carlos' response

* Remove wrong example script

* Remove rasterio dependencies from lists

* First try to prevent testing error

* Changes Daniele and fix knmi nwp importer

* Add rasterio to tox.ini

* Aesthetics

* rasterio import test

* Add rasterio to the test dependencies

* Reset try-except functionality for rasterio import

* Fix for failing test on windows python 3.6

* add importerskip rasterio

Co-authored-by: Wout Dewettinck <wout.dewettinck@ugent.be>

* Revert "Merge branch 'steps_blending' into pysteps-v2" (#239)

This reverts commit 2c639f8, reversing
changes made to bccb8fc.

Co-authored-by: ned <daniele.nerini@meteoswiss.ch>
Co-authored-by: dnerini <daniele.nerini@gmail.com>
Co-authored-by: Wout Dewettinck <wout.dewettinck@ugent.be>

* NWP skill calculation only within radar domain

* Update docs

* Add example for gallery examples

* Fix docstrings example

* Remove additional normalization step

* Fixes for the tests

* update docs

* changes to post-processing rainfall field and docstrings

* Update contributing guidelines (#241)

- Improve grammar.
- Make the guide more concise. Remove unused/unnecessary rules.
- Indicate more clearly which parts of the guidelines are inspired by other projects (before they were only mentioned at the end).
- Change "Travis-CI" references by "GitHub Actions".

* Advect noise cascade

* Allow for moving domain mask of extrapolation component

* minor fixes

* Linear blending (#229)

* Implemented linear blending function
* Added example file and test
* Added compatibility for NWP ensembles

The PR is ready to go. Making the code xarray ready will be done in a separate PR. 

Co-authored-by: RubenImhoff <r.o.imhoff@live.nl>

* weights calculation adjustment outside radar domain if only one model present

* allow for mirroring of advected noise cascade

* implementation of weights following Seed et al. (2013)

* Allow for decomposed NWP precip and NWP velocity fields: part 2

* Store decomposed fields with compression

* changes after first review Daniele

* Remove unnecessary print statement

* fixes to blending utils and implementation of blending utils tests

* remove unnecessary lines

* Fix one time step shift of extrapolation skill prior to blending

* minor changes to blending climatology, blending weights and remove path_workdir from pystepsrc

* Make NWP forecast decomposition prior to blending function optional

* Use pathlib

* Extract methods

* Minor changes to docstrings

* Access climatological skill file for multiple NWP model and date string changes to prevent errors in blending.utils

Co-authored-by: Carlos Velasco <carlos.velasco@bom.gov.au>
Co-authored-by: ned <daniele.nerini@meteoswiss.ch>
Co-authored-by: Andres Perez Hortal <16256571+aperezhortal@users.noreply.github.com>
Co-authored-by: Ruben Imhoff <Ruben.Imhoff@deltares.nl>
Co-authored-by: Carlos Velasco <cvelascof@gmail.com>
Co-authored-by: Lesley De Cruz <lesley.decruz+git@gmail.com>
Co-authored-by: Wout Dewettinck <wout.dewettinck@ugent.be>
Co-authored-by: wdewettin <87696913+wdewettin@users.noreply.github.com>
Co-authored-by: Lesley De Cruz <lesley.decruz@meteo.be>
Co-authored-by: dnerini <daniele.nerini@gmail.com>
dnerini added a commit that referenced this pull request Jan 14, 2022
* First basic functions to implement STEPS blending

* Add compute of blend means,sigmas and recompose

* pysteps.io with xarray (#219)

* Add xarray dependency

* MCH importer returns an xarray Dataset

* Remove plot lines

* Remove import

* Adapt readers to xarray format

* Rewrite as more general decorator

* Add missing metadata

* Adapt io tests

* Mrms bounding box (#222)

* Fix bounding box coordinates

* Add missing metadata

* Import xarray DataArray

Ignore quality field

* Black

* Do not hardcode metadata

* Address review comments by ruben

* Add a legacy option to the io functions

A "legacy" options is added to revert back the importers and readers behavior to version 1. This is a temporary solution to allow the examples, and other functions, to run as usual (v1.*).

Hopefully, this is will allow a easier transition into version 2 during the development process and will allow testing functions that were not updated to v2.

* Fix compatibility problems with tests

Many of the tests were updated to use the legacy data structures (v1). The tests that still contains issues, were tagged with a TODO message and they are skipped.

This will allow incremental changes to be tested in the new v2.

IMPORTANT: once the v2 branch is stable, we may remove the legacy compatibility from the code base and the tests.

* Update dependencies

* Ignore plugins test

Co-authored-by: Andres Perez Hortal <16256571+aperezhortal@users.noreply.github.com>

* Add blend_optical_flow

* changes to steps blending procedure - weights according to adjusted BPS2006 method

* changes to blending procedures - adjust weights from original BPS2006 method

* Determine spatial correlation of NWP model forecast

* First attempt to make correlations and thus weights lead time dependent (in progress..)

* Change back to original BPS2006 blending formulation and add regression of skill values to climatological values for weights determination

* Reformat code with Black

* Skill score script imports climatological correlation-values from file now

* Small changes to skill score script

* Add skill score tests and an interface

* Add skill score tests and an interface

* Small change to docstring

* Bom import xarray (#228)

* Add import_bom_rf3  using xarray

* Add tests to xarray version

* Fix mrms importer tests

* Pass **kwargs to internal functions

* Add nwp_importers to read bom nwp sample data

* Add bom nwp data to source file

* Add tests for bom_nwp reader

* Fix pystepsrc

Co-authored-by: Andres Perez Hortal <16256571+aperezhortal@users.noreply.github.com>

* Functions to store and compute climatological weights (#231)

* Implement the functions get_default_weights, save_weights, calc_clim_weights.

These functions are used to evolve the weights in the scale- and skill-dependent blending with NWP in the STEPS blending algorithm. The current weights, based on the correlations per cascade level, are regressed towards these climatological weights in the course of the forecast.

These functions save the current and compute the climatological weights (a running mean of the weights of the past n days, where typically n=30). First daily averages are stored and these are then averaged over the running window of n days.

* Add tests for pysteps climatological weight io and calculations.

* Add path_workdir to outputs section in pystepsrc file and use it as a default path to store/retrieve blending weights.

* Minor changes to docstrings, changes to skill scores and testing scripts

* Completed documentation for blending clim module, cleanup.

Co-authored-by: RubenImhoff <r.o.imhoff@live.nl>

* Main blending module, first steps

* Add simple tests

* Minor changes to tester: velocity now based on rainfall field of NWP

* Add utilities to decompose, store and load NWP cascades for use in blending  (#232)

* First version of NWP decomposition

* Added saving to netCDF

* Completed functions for saving and loading decomposed NWP data

* Added example files for the decomposed NWP functions

* Added compatibility with numpy datetime

* Use default output path_workdir for tmp files in blending/utils.py.

* Update documentation of NWP decomposition functions in utils.py

Co-authored-by: Wout Dewettinck <wout.dewettinck@ugent.be>
Co-authored-by: wdewettin <87696913+wdewettin@users.noreply.github.com>

* Add importer for RMI NWP data (#234)

Add importer for netcdf NWP data from RMI using xarrays.

* Add test for RMI NWP data importer.

* Add entry for RMI NWP data in pystepsrc.

* Run black on everything: fix formatting.

* Add KNMI Harmonie NWP netcdf importer and tests (#235)

* Changes to v_models to make use of multiple timesteps. Changes in the velocity field over time in the NWP forecast will be taken into account now.

* Fixes for KNMI importer:

Add forgotten @postprocess_import()
Don't call dropna on NWP data.

* Avoid shadowing of pysteps.blending.utils by pysteps.utils

* First attempt for probability matching and masking utility; part 1

* Changes to prob matching and masking methods; part 2

* Prob matching and masking changes; part 3. Ready for testing with real data from here on

* Remove unnecessary print statements

* Cleanup imports

* More cleanup

* Update docstrings

* RMI importer for gallery example (will follow)

* Reprojection functionality (#236)

* Added Lesley's reprojection module to this branch

* Added compatibility for three-dimensional xarrays

* Add commentary to reprojection util

* Changes to make reprojection of KNMI data possible

* Changes after Daniele's review

* Add dependencies

* Changes to importers, see issue #215

* Add tests

* Fix some issues

* documentation

* Fixes for tests

* Set requirements again

* Some fixes

* Changes to nwp_importers after Carlos' response

* Remove wrong example script

* Remove rasterio dependencies from lists

* First try to prevent testing error

* Changes Daniele and fix knmi nwp importer

* Add rasterio to tox.ini

* Aesthetics

* rasterio import test

* Add rasterio to the test dependencies

* Reset try-except functionality for rasterio import

* Fix for failing test on windows python 3.6

* add importerskip rasterio

Co-authored-by: Wout Dewettinck <wout.dewettinck@ugent.be>

* Fixes in nwp importers

* Revert "Merge branch 'steps_blending' into pysteps-v2" (#239)

This reverts commit 2c639f8, reversing
changes made to bccb8fc.

* Merge latest version pysteps-v2 into steps_blending branch (#237)

* Update docstrings

* More cleanup

* Cleanup imports

* Cleanup imports

* More cleanup

* Update docstrings

* Update references

Mention the work of Ravuri et al (2021, Nature) as an example of work using cGANs to generate ensembles

* Clean up page

* Reprojection functionality (#236)

* Added Lesley's reprojection module to this branch

* Added compatibility for three-dimensional xarrays

* Add commentary to reprojection util

* Changes to make reprojection of KNMI data possible

* Changes after Daniele's review

* Add dependencies

* Changes to importers, see issue #215

* Add tests

* Fix some issues

* documentation

* Fixes for tests

* Set requirements again

* Some fixes

* Changes to nwp_importers after Carlos' response

* Remove wrong example script

* Remove rasterio dependencies from lists

* First try to prevent testing error

* Changes Daniele and fix knmi nwp importer

* Add rasterio to tox.ini

* Aesthetics

* rasterio import test

* Add rasterio to the test dependencies

* Reset try-except functionality for rasterio import

* Fix for failing test on windows python 3.6

* add importerskip rasterio

Co-authored-by: Wout Dewettinck <wout.dewettinck@ugent.be>

* Revert "Merge branch 'steps_blending' into pysteps-v2" (#239)

This reverts commit 2c639f8, reversing
changes made to bccb8fc.

Co-authored-by: ned <daniele.nerini@meteoswiss.ch>
Co-authored-by: dnerini <daniele.nerini@gmail.com>
Co-authored-by: Wout Dewettinck <wout.dewettinck@ugent.be>

* NWP skill calculation only within radar domain

* Update docs

* Add example for gallery examples

* Fix docstrings example

* Remove additional normalization step

* Fixes for the tests

* update docs

* changes to post-processing rainfall field and docstrings

* Update contributing guidelines (#241)

- Improve grammar.
- Make the guide more concise. Remove unused/unnecessary rules.
- Indicate more clearly which parts of the guidelines are inspired by other projects (before they were only mentioned at the end).
- Change "Travis-CI" references by "GitHub Actions".

* Advect noise cascade

* Allow for moving domain mask of extrapolation component

* minor fixes

* Linear blending (#229)

* Implemented linear blending function
* Added example file and test
* Added compatibility for NWP ensembles

The PR is ready to go. Making the code xarray ready will be done in a separate PR.

Co-authored-by: RubenImhoff <r.o.imhoff@live.nl>

* weights calculation adjustment outside radar domain if only one model present

* allow for mirroring of advected noise cascade

* implementation of weights following Seed et al. (2013)

* Allow for decomposed NWP precip and NWP velocity fields: part 2

* Store decomposed fields with compression

* changes after first review Daniele

* Remove unnecessary print statement

* fixes to blending utils and implementation of blending utils tests

* remove unnecessary lines

* Fix one time step shift of extrapolation skill prior to blending

* minor changes to blending climatology, blending weights and remove path_workdir from pystepsrc

* Make NWP forecast decomposition prior to blending function optional

* Use pathlib

* Extract methods

* Minor changes to docstrings

* Access climatological skill file for multiple NWP model and date string changes to prevent errors in blending.utils

Co-authored-by: Carlos Velasco <carlos.velasco@bom.gov.au>
Co-authored-by: ned <daniele.nerini@meteoswiss.ch>
Co-authored-by: Andres Perez Hortal <16256571+aperezhortal@users.noreply.github.com>
Co-authored-by: Ruben Imhoff <Ruben.Imhoff@deltares.nl>
Co-authored-by: Carlos Velasco <cvelascof@gmail.com>
Co-authored-by: Lesley De Cruz <lesley.decruz+git@gmail.com>
Co-authored-by: Wout Dewettinck <wout.dewettinck@ugent.be>
Co-authored-by: wdewettin <87696913+wdewettin@users.noreply.github.com>
Co-authored-by: Lesley De Cruz <lesley.decruz@meteo.be>
Co-authored-by: dnerini <daniele.nerini@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

Implement linear blending
5 participants