From e3c83cec948c73a438fc95449b7f34de8f02f1b3 Mon Sep 17 00:00:00 2001 From: Jack Atkinson Date: Mon, 19 Feb 2024 17:30:39 +0000 Subject: [PATCH 1/4] Move code inside newCAM_emulation directory ready for packaging. --- Model.py => newCAM_emulation/Model.py | 0 NN_pred.py => newCAM_emulation/NN_pred.py | 0 loaddata.py => newCAM_emulation/loaddata.py | 0 train.py => newCAM_emulation/train.py | 6 +++--- 4 files changed, 3 insertions(+), 3 deletions(-) rename Model.py => newCAM_emulation/Model.py (100%) rename NN_pred.py => newCAM_emulation/NN_pred.py (100%) rename loaddata.py => newCAM_emulation/loaddata.py (100%) rename train.py => newCAM_emulation/train.py (96%) diff --git a/Model.py b/newCAM_emulation/Model.py similarity index 100% rename from Model.py rename to newCAM_emulation/Model.py diff --git a/NN_pred.py b/newCAM_emulation/NN_pred.py similarity index 100% rename from NN_pred.py rename to newCAM_emulation/NN_pred.py diff --git a/loaddata.py b/newCAM_emulation/loaddata.py similarity index 100% rename from loaddata.py rename to newCAM_emulation/loaddata.py diff --git a/train.py b/newCAM_emulation/train.py similarity index 96% rename from train.py rename to newCAM_emulation/train.py index a8c1314..7379560 100644 --- a/train.py +++ b/newCAM_emulation/train.py @@ -40,8 +40,8 @@ def early_stop(self, validation_loss): ## load mean and std for normalization -fm = np.load('Demodata/mean_demo_sub.npz') -fs = np.load('Demodata/std_demo_sub.npz') +fm = np.load('../Demodata/mean_demo_sub.npz') +fs = np.load('../Demodata/std_demo_sub.npz') Um = fm['U'] Vm = fm['V'] @@ -92,7 +92,7 @@ def early_stop(self, validation_loss): if (iter > 1): model.load_state_dict(torch.load('conv_torch.pth')) print ('data loader iteration',iter) - filename = './Demodata/newCAM_demo_sub_' + str(iter).zfill(1) + '.nc' + filename = '../Demodata/newCAM_demo_sub_' + str(iter).zfill(1) + '.nc' print('working on: ', filename) F = nc.Dataset(filename) From 8aabbbbaab23316d31c2a3946307107793435792 Mon Sep 17 00:00:00 2001 From: Jack Atkinson Date: Mon, 19 Feb 2024 17:31:42 +0000 Subject: [PATCH 2/4] Add pyproject.toml file for packaging and to allow installation of dependencies and metadata. --- pyproject.toml | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..572ca9a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,61 @@ +[build-system] +requires = ["setuptools >= 61"] +build-backend = "setuptools.build_meta" + +[project] +name = "newCAM_emulation" +version = "0.0.0" +description = "PyTorch Net to emulate the gravity wave drag in CAM" +authors = [ + { name="Qiang Sun", email="qiangsun@uchicago.edu" }, +] +readme = "README.md" +license = {file = "LICENSE"} +requires-python = ">=3.9" +classifiers = [ + "License :: OSI Approved :: MIT License", + "Development Status :: 3 - Alpha", + "Natural Language :: English", + "Programming Language :: Python :: 3", + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Typing :: Typed', + "Operating System :: OS Independent", +] + +dependencies = [ + "numpy>=1.20.0", + "torch", + "torchvision", + "scipy", + "matplotlib", + "xarray", + "netcdf4", +] + +[project.optional-dependencies] +lint = [ + "black>=24.1.0", + "pylint", + # "mypy>=1.0.0", + # "pytest>=7.2.0", + # "pytest-mock", + "pydocstyle", +] + +[project.urls] +"Homepage" = "https://github.com/DataWaveProject/newCAM_emulation" +"Bug Tracker" = "https://github.com/DataWaveProject/newCAM_emulation/issues" + +[tool.setuptools] +# By default, include-package-data is true in pyproject.toml, so you do +# NOT have to specify this line. +include-package-data = true + +[tool.setuptools.packages.find] +where = ["."] # list of folders that contain the packages (["."] by default) +include = ["newCAM_emulation*"] # package names should match these glob patterns (["*"] by default) +exclude = ["Demodata/*"] # exclude packages matching these glob patterns (empty by default) +namespaces = false # to disable scanning PEP 420 namespaces (true by default) From 400279790ba78383d3678940df7d87c6abf3ab56 Mon Sep 17 00:00:00 2001 From: Jack Atkinson Date: Mon, 19 Feb 2024 17:50:41 +0000 Subject: [PATCH 3/4] Add basic install instructions to the README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index fafb677..635c061 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,15 @@ It is 3D global output from the mid-top CAM model, on the original model grid. However, the demo data here is one very small part of the CAM output due to storage limit of Github. NN trained on this Demodata will not work. +# Installing + +Clone this repo and enter it.\ +Then run: +``` +pip install . +``` +to install the neccessary dependencies.\ +It is recommended this is done from inside a virtual environment. # data loader load 3D CAM data and reshaping them to the NN input. From 56aaf9bc46faca0ee1520cdf271657efdcb4de27 Mon Sep 17 00:00:00 2001 From: Jack Atkinson Date: Mon, 19 Feb 2024 17:57:19 +0000 Subject: [PATCH 4/4] Add bare __init__.py --- newCAM_emulation/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 newCAM_emulation/__init__.py diff --git a/newCAM_emulation/__init__.py b/newCAM_emulation/__init__.py new file mode 100644 index 0000000..e69de29