|
1 | 1 | #!/usr/bin/env python
|
2 | 2 | u"""
|
3 | 3 | aod1b_geocenter.py
|
4 |
| -Written by Tyler Sutterley (05/2021) |
| 4 | +Written by Tyler Sutterley (07/2021) |
| 5 | +Contributions by Hugo Lecomte (03/2021) |
5 | 6 |
|
6 | 7 | Reads GRACE/GRACE-FO level-1b dealiasing data files for a specific product
|
7 | 8 | atm: atmospheric loading from ECMWF
|
8 | 9 | ocn: oceanic loading from OMCT/MPIOM
|
9 | 10 | glo: global atmospheric and oceanic loading
|
10 | 11 | oba: ocean bottom pressure from OMCT/MPIOM
|
11 | 12 |
|
12 |
| -Creates monthly files of geocenter variations at 6-hour intervals |
| 13 | +Creates monthly files of geocenter variations at 3 or 6 hour intervals |
13 | 14 |
|
14 | 15 | NOTE: this reads the GFZ AOD1B files downloaded from PO.DAAC
|
15 | 16 | https://podaac-uat.jpl.nasa.gov/drive/files/allData/grace/L1B/GFZ/AOD1B/RL06/
|
|
30 | 31 |
|
31 | 32 | PROGRAM DEPENDENCIES:
|
32 | 33 | geocenter.py: converts degree 1 spherical harmonics to geocenter variations
|
| 34 | + utilities.py: download and management utilities for files |
33 | 35 |
|
34 | 36 | UPDATED HISTORY:
|
| 37 | + Updated 07/2021: can use default argument files to define options |
35 | 38 | Updated 05/2021: define int/float precision to prevent deprecation warning
|
| 39 | + Updated 03/2021: Add 3-hour interval depending on Release |
36 | 40 | Updated 10/2020: use argparse to set command line parameters
|
37 | 41 | Updated 07/2020: added function docstrings
|
38 | 42 | Updated 06/2019: using python3 compatible regular expression patterns
|
|
58 | 62 | import argparse
|
59 | 63 | import numpy as np
|
60 | 64 | from gravity_toolkit.geocenter import geocenter
|
61 |
| - |
62 |
| -#-- aod1b data products |
63 |
| -product = {} |
64 |
| -product['atm'] = 'Atmospheric loading from ECMWF' |
65 |
| -product['ocn'] = 'Oceanic loading from OMCT' |
66 |
| -product['glo'] = 'Global atmospheric and oceanic loading' |
67 |
| -product['oba'] = 'Ocean bottom pressure from OMCT' |
| 65 | +import gravity_toolkit.utilities as utilities |
68 | 66 |
|
69 | 67 | #-- program module to read the degree 1 coefficients of the AOD1b data
|
70 | 68 | def aod1b_geocenter(base_dir, DREL='', DSET='', CLOBBER=False, MODE=0o775,
|
71 | 69 | VERBOSE=False):
|
72 | 70 | """
|
73 |
| - Creates monthly files of geocenter variations at 6-hour intervals from |
| 71 | + Creates monthly files of geocenter variations at 6-hour or 3-hour intervals from |
74 | 72 | GRACE/GRACE-FO level-1b dealiasing data files
|
75 | 73 |
|
76 | 74 | Arguments
|
@@ -105,11 +103,32 @@ def aod1b_geocenter(base_dir, DREL='', DSET='', CLOBBER=False, MODE=0o775,
|
105 | 103 | #-- output formatting string
|
106 | 104 | fstr = '{0:4d}-{1:02d}-{2:02d}T{3:02d}:00:00 {4:12.8f} {5:12.8f} {6:12.8f}'
|
107 | 105 |
|
108 |
| - #-- Maximum spherical harmonic degree (LMAX) |
109 |
| - LMAX = 100 |
| 106 | + #-- set number of hours in a file |
| 107 | + #-- set the ocean model for a given release |
| 108 | + if DREL in ('RL01','RL02','RL03','RL04','RL05'): |
| 109 | + #-- for 00, 06, 12 and 18 |
| 110 | + n_time = 4 |
| 111 | + ATMOSPHERE = 'ECMWF' |
| 112 | + OCEAN_MODEL = 'OMCT' |
| 113 | + LMAX = 100 |
| 114 | + elif DREL in ('RL06',): |
| 115 | + #-- for 00, 03, 06, 09, 12, 15, 18 and 21 |
| 116 | + n_time = 8 |
| 117 | + ATMOSPHERE = 'ECMWF' |
| 118 | + OCEAN_MODEL = 'MPIOM' |
| 119 | + LMAX = 180 |
| 120 | + else: |
| 121 | + raise ValueError('Invalid data release') |
110 | 122 | #-- Calculating the number of cos and sin harmonics up to LMAX
|
111 | 123 | n_harm = (LMAX**2 + 3*LMAX)//2 + 1
|
112 | 124 |
|
| 125 | + #-- AOD1B data products |
| 126 | + product = {} |
| 127 | + product['atm'] = 'Atmospheric loading from {0}'.format(ATMOSPHERE) |
| 128 | + product['ocn'] = 'Oceanic loading from {0}'.format(OCEAN_MODEL) |
| 129 | + product['glo'] = 'Global atmospheric and oceanic loading' |
| 130 | + product['oba'] = 'Ocean bottom pressure from {0}'.format(OCEAN_MODEL) |
| 131 | + |
113 | 132 | #-- AOD1B directory and output geocenter directory
|
114 | 133 | grace_dir = os.path.join(base_dir,'AOD1B',DREL)
|
115 | 134 | output_dir = os.path.join(grace_dir,'geocenter')
|
@@ -169,15 +188,15 @@ def aod1b_geocenter(base_dir, DREL='', DSET='', CLOBBER=False, MODE=0o775,
|
169 | 188 | else:
|
170 | 189 | fid = tar.extractfile(member)
|
171 | 190 | #-- degree 1 spherical harmonics for day and hours
|
172 |
| - C10 = np.zeros((4)) |
173 |
| - C11 = np.zeros((4)) |
174 |
| - S11 = np.zeros((4)) |
175 |
| - hours = np.zeros((4),dtype=np.int64) |
| 191 | + C10 = np.zeros((n_time)) |
| 192 | + C11 = np.zeros((n_time)) |
| 193 | + S11 = np.zeros((n_time)) |
| 194 | + hours = np.zeros((n_time),dtype=np.int64) |
176 | 195 |
|
177 | 196 | #-- create counter for hour in dataset
|
178 | 197 | c = 0
|
179 | 198 | #-- while loop ends when dataset is read
|
180 |
| - while (c < 4): |
| 199 | + while (c < n_time): |
181 | 200 | #-- read line
|
182 | 201 | file_contents = fid.readline().decode('ISO-8859-1')
|
183 | 202 | #-- find file header for data product
|
@@ -220,9 +239,11 @@ def main():
|
220 | 239 | #-- Read the system arguments listed after the program
|
221 | 240 | parser = argparse.ArgumentParser(
|
222 | 241 | description="""Creates monthly files of geocenter variations
|
223 |
| - at 6-hour intervals |
224 |
| - """ |
| 242 | + at 3 or 6-hour intervals |
| 243 | + """, |
| 244 | + fromfile_prefix_chars="@" |
225 | 245 | )
|
| 246 | + parser.convert_arg_line_to_args = utilities.convert_arg_line_to_args |
226 | 247 | #-- command line parameters
|
227 | 248 | #-- working data directory
|
228 | 249 | parser.add_argument('--directory','-D',
|
|
0 commit comments