Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dachar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import dachar
CONFIG = get_config(dachar)

from clisops import logging
# from clisops import logging
import logging

from .fixes import *
from .scan import *
from .utils import *
from .analyse import *
from .analyse import *
from .decadal import generate_decadal_fix
20 changes: 12 additions & 8 deletions generate_decadal_fix.py → dachar/decadal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import xarray as xr
from roocs_utils.project_utils import dsid_to_datapath

ETC_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), 'etc'))


def arg_parse():

Expand Down Expand Up @@ -171,21 +173,15 @@ def get_ds_ids(fpath):
return ds_ids


def main():
args = arg_parse()

fpath = args.fpath
ds_id = args.dsid

def generate_decadal_fix(fpath, ds_id):
data_path = dsid_to_datapath(ds_id)

# put into template
dt = get_decadal_template()

dt["dataset_id"] = ds_id

pathname = os.path.dirname(sys.argv[0])
if ds_id in get_ds_ids(os.path.join(pathname, "further_info_url-dsets.txt")):
if ds_id in get_ds_ids(os.path.join(ETC_DIR, "further_info_url-dsets.txt")):
global_attrs = dt["fixes"][1].get("operands").get("attrs")
global_attrs.update(
further_info_url="derive: daops.fix_utils.decadal_utils.fix_further_info_url"
Expand All @@ -196,6 +192,14 @@ def main():
with open(fpath, "w") as fp:
json.dump(dt, fp, indent=4)

def main():
args = arg_parse()

fpath = args.fpath
ds_id = args.dsid

generate_decadal_fix(fpath, ds_id)


if __name__ == "__main__":
main()
File renamed without changes.
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: dachar
channels:
- conda-forge
- defaults
dependencies:
- numpy>=1.16
- xarray>=0.15
Expand Down
1 change: 1 addition & 0 deletions notebooks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixes
10 changes: 10 additions & 0 deletions notebooks/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# conda env update -f environment.yml
name: dachar
channels:
- conda-forge
dependencies:
- pip
- ipython
- jupyterlab
- ipywidgets
- nodejs
78 changes: 78 additions & 0 deletions notebooks/publish-cmip6-decadal-fixes.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "2b2555ab-e3f2-492a-bda3-4688fca87528",
"metadata": {},
"source": [
"# Publish cmip6 decadal fixes"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3aea8323-442f-4025-a2c6-600708d7cb92",
"metadata": {},
"outputs": [],
"source": [
"import dachar\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "46daa659-0510-4f77-8c37-1c8e1db87120",
"metadata": {},
"outputs": [],
"source": [
"FIX_DIR = \"./fixes/cmip6-decadal\"\n",
"if not os.path.exists(FIX_DIR):\n",
" os.makedirs(FIX_DIR)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "35bf556f-1dbf-4200-8447-23013066df49",
"metadata": {},
"outputs": [],
"source": [
"DRS_ID = \"CMIP6.DCPP.MOHC.HadGEM3-GC31-MM.dcppA-hindcast.s2004-r3i1p1f2.Amon.pr.gn.v20200417\"\n",
"\n",
"FIX_PATH = f\"{FIX_DIR}/{DRS_ID}.json\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cbb309d0-3d51-4c56-8b0c-092338fc831f",
"metadata": {},
"outputs": [],
"source": [
"dachar.generate_decadal_fix(FIX_PATH, DRS_ID)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}