Reference
arakawa_points
Point
Class that represents the Arakawa points (i.e. center point, face, edge, etc).
Source code in xnemogcm/arakawa_points.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
__init__(point_type)
point_type : 'T', 'U', 'V', 'F', 'W', 'UW', 'VW', 'FW'
Source code in xnemogcm/arakawa_points.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
domcfg
domcfg_preprocess(ds)
Preprocess domcfg / meshmask files when needed to be recombined (= 1 file per processor)
Source code in xnemogcm/domcfg.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
open_domain_cfg(datadir=None, files=None, add_coordinates=True)
Return a dataset containing all dataarrays of the domain_cfg*.nc / mesh_mask files.
For that, open and merge all the datasets. The dataset is compatible with xgcm, the corresponding grid can be create through: xgcm.Grid(domcfg)
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in xnemogcm/domcfg.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
open_file_multi(files)
Open and merge netcdf file created on each processor by NEMO (e.g. domain_cfg of mesh_mask). If only one file is present, open and return it without any process.
2 methods are accepted: 1) give a directory pathdir and a file prefix (e.g. 'domain_cfg') file_prefix, 2) give a list of file names files.
Source code in xnemogcm/domcfg.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
merge
open_nemo_and_domain_cfg(nemo_files=None, domcfg_files=None, nemo_kwargs=None, domcfg_kwargs=None, linear_free_surface=False)
Open nemo_ds and domcfg with open_nemo and open_domain_cfg and merge them with _merge_nemo_and_domain_cfg.
See the respective functions docstrings for more details.
2 methods are available for nemo files and domain_cfg/mesh_mask files: 1) provide a list of the files you want to open, 2) provide the path of the directories containing the files and xnemogcm will try to open as much files as it can.
Arguments
nemo_files : Optional, list / generator or string / Path 1) list / generator containing the nemo output files, or 2) string / Path of the directory containing the nemo output files. Will open all files containing "grid_X" in their name, "X" being "T", "U", "V", "W", "F", etc domcfg_files : Optional, list / generator or string / Path 1) list / generator containing the domain_cfg / mesh_mask files, or 2) string / Path of the directory containing the domain_cfg / mesh_mask output files. Will open all files containing "domain_cfg" or "mesh_mask" in their name. nemo_kwargs : dict dict containing the parameters of the xnemogcm.open_nemo function Can contain the files and/or datadir arguments of the open_nemo function e.g. {'chunks':{'time_counter':10}} domcfg_kwargs : dict dict containing the parameters of the xnemogcm.open_domain_cfg function Can contain the files and/or datadir arguments of the open_domain_cfg function linear_free_surface : bool True if linear free surface is used. Used by xnemogcm._merge_nemo_and_domain_cfg function
Source code in xnemogcm/merge.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
metrics
compute_missing_metrics(ds, all_scale_factors=all_scale_factors, time_varying=True)
Add all possible scale factors to the dataset.
For the moment, e3t (or e3t_0) at least needs to be present in the dataset for the time_varying=True (time_varying=False) case. If e3t_0 is not found (e.g. for nemo 3.6), it will raise a warning and use e3t_1d (this will lead to wrong results if terrain-following coordinates are used).
May have some boundary issues, and only non-periodic boundaries are implemented.
Will add the metrics to the given dataset. To avoid this, use a ds.copy()
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in xnemogcm/metrics.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
get_metrics(ds)
Return a dict with the available metrics, to be used with xgcm.Grid
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in xnemogcm/metrics.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
namelist
open_namelist(datadir=None, files=None, ref=True, cfg=True)
Open the namelist and store it into a xarray.Dataset
Source code in xnemogcm/namelist.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
nemo
nemo_preprocess(ds, domcfg, point_type=None)
Preprocess function for the nemo files.
This function renames the time dimension 'time_counter' into 't', 'time_counter_bounds' into 't_bounds'. It removes the old 'nav_lat' and 'nav_lon' variables and sets the 'x', 'y', and 'z' dimensions into the correct dimension, depending on the grid point (e.g. ['x_c', 'y_c', 'z_c'] for T point).
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in xnemogcm/nemo.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
open_nemo(domcfg, datadir=None, files=None, chunks=None, parallel=False, **kwargs_open)
Open nemo dataset, and rename the coordinates to be conform to xgcm.Grid
The filenames must finish with 'grid_X.nc', with X in ['T', 'U', 'V', 'W', 'UW', 'VW', 'FW'] OR the global attribute 'description' of each individual file must be 'ocean X grid variables' with X in ['T', 'U', ...]
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in xnemogcm/nemo.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
process_nemo(positions, domcfg, parallel=False)
Process datasets from NEMO outputs and set coordinates and attributes.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in xnemogcm/nemo.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
tools
get_domcfg_points()
The points are hard coded at hand to be sure to not introduce errors from the reading of the names
Source code in xnemogcm/tools.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |