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

Refactored main and restructured code #31

Open
wants to merge 33 commits into
base: develop
Choose a base branch
from
Open

Refactored main and restructured code #31

wants to merge 33 commits into from

Conversation

ray-chew
Copy link
Owner

__main__.py is now cleaned, and all the initialisation and analysis steps have been moved to their respective modules or subpackages.

…tructure

there are still a lot of broken imports and references, so the code does not run yet.
…_main__.py

still untested as I have to move the analysis steps to the DA subpackage before this will run
also created a placeholder for the parallel integrator tests planned
the restructuring continues
DA and blending are not covered in the tests, will look into them after refactoring the flow solver
since I removed all initial conditions except this
@ray-chew ray-chew added this to the Refactor milestone Dec 18, 2024
@ray-chew ray-chew requested a review from tbnc December 18, 2024 17:24
@tbnc
Copy link
Collaborator

tbnc commented Jan 6, 2025

I will review.

Are the docs checks supposed to succeed?

@ray-chew
Copy link
Owner Author

ray-chew commented Jan 6, 2025

I will review.

Are the docs checks supposed to succeed?

Thank you. The checks broke due to the renaming of the subpackages. This issue has been resolved with the latest commits. But the pytests are broken now, as I am in the midst of restructuring the diagnostics module to accept more general definitions of test cases.

more cleaning up is due for the diagnostics modules, but at least now the tests are no longer hardcoded. the blending has potential problems with failing tests, will look into this next.
However, the codebase is structured such that the user can easily assemble a run script to define their own experiments. Refer to the documentation for the [available APIs](https://ray-chew.github.io/pyBELLA/apis.html).
To run a simulation:
```console
pybella -ic rb -N 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does not appear to work, at least out of the box:

[nhad@ac6-101 pyBELLA]$ pybella -ic rb -N 1
Traceback (most recent call last):
  File "/home/nhad/.local/bin/pybella", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/etc/ecmwf/nfs/dh1_home_b/nhad/pyBELLA/src/__main__.py", line 30, in main
    sim_state = prepare.initialise()
                ^^^^^^^^^^^^^^^^^^^^
  File "/etc/ecmwf/nfs/dh1_home_b/nhad/pyBELLA/src/utils/prepare.py", line 43, in initialise
    ud.coriolis_strength = np.array(ud.coriolis_strength)
                                    ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'UserDataInit' object has no attribute 'coriolis_strength'

@@ -1,16 +0,0 @@
import pytest
Copy link
Collaborator

Choose a reason for hiding this comment

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

Line 74 in the README

pytest ./run_scripts/test_dycore.py -v
should take into account the fact that the file has been deleted.

However, the codebase is structured such that the user can easily assemble a run script to define their own experiments. Refer to the documentation for the [available APIs](https://ray-chew.github.io/pyBELLA/apis.html).
To run a simulation:
```console
pybella -ic rb -N 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does not appear to work, at least not out of the box:

[nhad@ac6-101 pyBELLA]$ pybella -ic rb -N 1
Traceback (most recent call last):
  File "/home/nhad/.local/bin/pybella", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/etc/ecmwf/nfs/dh1_home_b/nhad/pyBELLA/src/__main__.py", line 30, in main
    sim_state = prepare.initialise()
                ^^^^^^^^^^^^^^^^^^^^
  File "/etc/ecmwf/nfs/dh1_home_b/nhad/pyBELLA/src/utils/prepare.py", line 43, in initialise
    ud.coriolis_strength = np.array(ud.coriolis_strength)
                                    ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'UserDataInit' object has no attribute 'coriolis_strength'

@@ -0,0 +1,123 @@
import logging
Copy link
Collaborator

Choose a reason for hiding this comment

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

With a view to the forthcoming published version, I would propose removing commented code lines sooner rather than later unless still part of prototyping (which probably should not end up in develop anyway?) or there is another very compelling reason to keep them in.

mpv,
t,
sst,
mem,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice and compact

@ray-chew ray-chew changed the title Refactored main andrestructured code Refactored main and restructured code Jan 10, 2025
"PyYAML==6.0",
"scipy==1.7.3",
"termcolor==2.4.0"
"dask",
Copy link
Collaborator

Choose a reason for hiding this comment

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

2024.2.1

@@ -3,15 +3,15 @@ name = "pyBELLA"
version = "0.50.1"

dependencies = [
"dask==2022.7.0",
"dill==0.3.6",
Copy link
Collaborator

Choose a reason for hiding this comment

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

0.3.8

@@ -3,15 +3,15 @@ name = "pyBELLA"
version = "0.50.1"

dependencies = [
"dask==2022.7.0",
"dill==0.3.6",
"h5py==3.7.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

3.12.1

"dask==2022.7.0",
"dill==0.3.6",
"h5py==3.7.0",
"matplotlib==3.5.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

3.8.4

"dill==0.3.6",
"h5py==3.7.0",
"matplotlib==3.5.1",
"numba==0.56.4",
Copy link
Collaborator

Choose a reason for hiding this comment

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

0.60.0

"h5py==3.7.0",
"matplotlib==3.5.1",
"numba==0.56.4",
"numpy==1.22.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

1.26.4

"matplotlib==3.5.1",
"numba==0.56.4",
"numpy==1.22.1",
"PyYAML==6.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

6.0.2

"numba==0.56.4",
"numpy==1.22.1",
"PyYAML==6.0",
"scipy==1.7.3",
Copy link
Collaborator

Choose a reason for hiding this comment

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

1.14.1

"numpy==1.22.1",
"PyYAML==6.0",
"scipy==1.7.3",
"termcolor==2.4.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

2.4.0

I was not updating mem attributes in the time update while loop. This means that everytime the blending scheme sees mem, it resets the solution fields to the beginning of the assimilation window.
I have not yet checked if the initial blending results are correct; will do this via the diagnostics module, but it does not work yet, as I have not yet generalised the target generation features.
…compare

nothing really works yet, because there seems to be a discrepancy between the target saved and the test values computed and compared against the target values. This has something to do with how the time steps are counted. Will need to carry on debugging.
the generalised target generation in the diagnostics module now works, the problem was with writing the output before the mem attributes were correctly updated.
…ted with warm bubble test values

blending is still switched off, but this commit allows for blending to be tested as a next step. woohoo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants