Load
ds_month_shift(ds, decode_times=True)
When loading CESM data, for some reason the first month is marked as February, so this function shifts the time variable to correct it to January.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ds
|
Dataset
|
Dataset to apply the shift to.
It should have been loaded with |
required |
decode_times
|
bool
|
If |
True
|
Returns:
Type | Description |
---|---|
Dataset
|
Dataset with first months shifted by -1 so now first month is January. |
Source code in isca_tools/cesm/load.py
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 |
|
get_exp_dir(exp_name, comp='atm', archive_dir=jasmin_archive_dir)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exp_name
|
str
|
Name of folder in |
required |
comp
|
str
|
Component of CESM to load data from. Options are:
|
'atm'
|
archive_dir
|
str
|
Directory where CESM archive data saved. |
jasmin_archive_dir
|
Returns:
Source code in isca_tools/cesm/load.py
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 |
|
get_exp_file_dates(exp_name, comp='atm', archive_dir=jasmin_archive_dir, hist_file=0)
Get dates indicated in file names of a particular experiment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exp_name
|
str
|
Name of folder in |
required |
comp
|
str
|
Component of CESM to load data from. Options are:
|
'atm'
|
archive_dir
|
str
|
Directory where CESM archive data saved. |
jasmin_archive_dir
|
hist_file
|
int
|
Which history file to load, |
0
|
Returns:
Type | Description |
---|---|
DataArray
|
DataArray of dates indicated in file names of |
Source code in isca_tools/cesm/load.py
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 232 233 234 235 236 237 |
|
load_dataset(exp_name, comp='atm', archive_dir=jasmin_archive_dir, hist_file=0, chunks=None, combine='nested', concat_dim='time', decode_times=True, parallel=False, preprocess=None, year_files=None, month_files=None, ind_files=None, apply_month_shift_fix=True, logger=None)
This loads a dataset of a given component produced by CESM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exp_name
|
str
|
Name of folder in |
required |
comp
|
str
|
Component of CESM to load data from. Options are:
|
'atm'
|
archive_dir
|
str
|
Directory where CESM archive data saved. |
jasmin_archive_dir
|
hist_file
|
int
|
Which history file to load, |
0
|
chunks
|
Optional[Union[dict, Literal['auto'], int]]
|
Dictionary with keys given by dimension names and values given by chunk sizes
e.g. |
None
|
combine
|
Literal['by_coords', 'nested']
|
Whether |
'nested'
|
concat_dim
|
str
|
Dimensions to concatenate files along. You only need to provide this argument if combine='nested'. |
'time'
|
parallel
|
bool
|
Whether parallel loading is performed. |
False
|
preprocess
|
Optional[Callable]
|
Function to preprocess the data before loading. |
None
|
decode_times
|
bool
|
If |
True
|
year_files
|
Optional[Union[int, List, str]]
|
Only files with these years in their name will be loaded. Leave as |
None
|
month_files
|
Optional[Union[int, List, str]]
|
Only files with these months (1 is Jan) in their names will be loaded.
Leave as |
None
|
ind_files
|
Optional[Union[int, List, str]]
|
Will save the files with these indices, when ordered by date. Takes precident over
|
None
|
apply_month_shift_fix
|
bool
|
If |
True
|
logger
|
Optional[Logger]
|
Optional logger. |
None
|
Returns:
Type | Description |
---|---|
Dataset
|
Dataset containing all diagnostics specified for the experiment. |
Source code in isca_tools/cesm/load.py
23 24 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 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 |
|
load_z2m(surf_geopotential_file=jasmin_surf_geopotential_file, var_reindex_like=None)
Returns 2m geopotential height for CESM simulation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
surf_geopotential_file
|
str
|
File location of input data containing the geopotential at the surface: |
jasmin_surf_geopotential_file
|
var_reindex_like
|
Optional[DataArray]
|
Can provide a variable so |
None
|
Returns:
Type | Description |
---|---|
DataArray
|
2m geopotential height in units of meters. |
Source code in isca_tools/cesm/load.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
parse_cesm_datetime(time_str)
Given a time string in the form either 'YYYY-MM' or 'YYYY-MM-DD-sssss' where sssss
are the seconds since midnight,
this will return the datetime object corresponding to that time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time_str
|
String to convert to datetime object. |
required |
Returns:
Type | Description |
---|---|
datetime
|
Datetime object corresponding to |
Source code in isca_tools/cesm/load.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
select_months(ds, month_nh, month_sh=None)
In dataset, keep only month_nh
months in the northern hemisphere, and month_sh
in the southern hemisphere.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ds
|
Dataset
|
Dataset to select months from. |
required |
month_nh
|
Union[ndarray, List[int]]
|
List of months to keep in northern hemisphere. |
required |
month_sh
|
Optional[Union[ndarray, List[int]]]
|
List of months to keep in southern hemisphere. If |
None
|
Returns:
Type | Description |
---|---|
Dataset
|
Dataset with months selected. |
Source code in isca_tools/cesm/load.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
|