Skip to content

Commit

Permalink
multi-resolution input processing with argparse
Browse files Browse the repository at this point in the history
  • Loading branch information
juannat7 committed Aug 13, 2024
1 parent 49b50d7 commit fee25f2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
13 changes: 9 additions & 4 deletions scripts/process_atmos.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import xarray as xr
from pathlib import Path
import config
Expand All @@ -7,12 +8,13 @@

import cdsapi

def main():
def main(args):
"""
Main driver to download ERA5 data based on individual variable
See https://cds.climate.copernicus.eu/api-how-to on how to configure the API
"""
RESOLUTION = '1.5' # Highest is 0.25
RESOLUTION = (args.resolution)
assert float(RESOLUTION) >= 0.25, 'Highest resolution is 0.25-degree, provide coarser one e.g., 1.5'

# Initialize CDS API
c = cdsapi.Client()
Expand Down Expand Up @@ -67,5 +69,8 @@ def main():
output_file.unlink()

if __name__ == "__main__":
main()

parser = argparse.ArgumentParser()
parser.add_argument('--resolution', default='1.5', help='Provide the resolution of preference, e.g., 1.5 for 1.5-degree...')

args = parser.parse_args()
main(args)
13 changes: 9 additions & 4 deletions scripts/process_land.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import xarray as xr
from pathlib import Path
import config
Expand All @@ -7,12 +8,13 @@

import cdsapi

def main():
def main(args):
"""
Main driver to download LRA5 data based on individual variable
See https://cds.climate.copernicus.eu/api-how-to on how to configure the API
"""
RESOLUTION = '1.5' # Highest is 0.25
RESOLUTION = str(args.resolution)
assert float(RESOLUTION) >= 0.25, 'Highest resolution is 0.25-degree, provide coarser one e.g., 1.5'

# Initialize CDS API
c = cdsapi.Client()
Expand Down Expand Up @@ -65,5 +67,8 @@ def main():
output_file.unlink()

if __name__ == "__main__":
main()

parser = argparse.ArgumentParser()
parser.add_argument('--resolution', default='1.5', help='Provide the resolution of preference, e.g., 1.5 for 1.5-degree...')

args = parser.parse_args()
main(args)
12 changes: 9 additions & 3 deletions scripts/process_ocean.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import xarray as xr
from pathlib import Path
import config
Expand All @@ -11,12 +12,13 @@

import cdsapi

def main():
def main(args):
"""
Main driver to download ORAS5 data based on individual variable
See https://cds.climate.copernicus.eu/api-how-to on how to configure the API
"""
RESOLUTION = '1.5' # Highest is 0.25
RESOLUTION = str(args.resolution)
assert float(RESOLUTION) >= 0.25, 'Highest resolution is 0.25-degree, provide coarser one e.g., 1.5'

# Initialize CDS API
c = cdsapi.Client()
Expand Down Expand Up @@ -108,4 +110,8 @@ def main():
nc_file.unlink()

if __name__ == "__main__":
main()
parser = argparse.ArgumentParser()
parser.add_argument('--resolution', default='1.5', help='Provide the resolution of preference, e.g., 1.5 for 1.5-degree...')

args = parser.parse_args()
main(args)

0 comments on commit fee25f2

Please sign in to comment.