sat_utils
Satellite Reader Utilities
add_time_coord(ds, time_val=None, time_attr=None)
Add a time dimension and coordinate to the dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Input dataset. |
required |
time_val
|
datetime
|
Explicit time value to use. |
None
|
time_attr
|
str
|
Attribute name to extract time from if time_val is None. |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset with 'time' dimension and coordinate. |
Source code in monetio/readers/sat_utils.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
apply_lazy_conversion(data, func, output_dtype)
Apply a conversion function lazily to a DataArray backend-agnostic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Input DataArray. |
required |
func
|
Callable
|
Function to apply. Should work on NumPy arrays. |
required |
output_dtype
|
Union[str, dtype, type]
|
Expected output dtype. |
required |
Returns:
| Type | Description |
|---|---|
DataArray
|
Converted DataArray. |
Source code in monetio/readers/sat_utils.py
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 | |
apply_qa_mask(ds, qa_var='qa_value', threshold=0.5)
Apply quality flag masking to a dataset.
Masks all data variables where the QA variable is below the threshold, while preserving the QA variable itself and all coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Input dataset containing a QA variable. |
required |
qa_var
|
str
|
Name of the quality flag variable. |
'qa_value'
|
threshold
|
float
|
Minimum acceptable quality value. |
0.5
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset with low-quality values masked as NaN. |
Source code in monetio/readers/sat_utils.py
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 | |
convert_ppmv_to_ppbv(ds, variables=None)
Convert gas-phase variables from ppmV to ppbV (multiply by 1000).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Input dataset. |
required |
variables
|
list of str
|
Variables to convert. If None, converts all variables with units containing 'ppm'. |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset with converted units. |
Source code in monetio/readers/sat_utils.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
jpss_time_to_datetime(time_array, origin='1958-01-01', unit='us')
Convert JPSS time (usually microseconds since 1958) to datetime64[ns].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_array
|
DataArray
|
Input time array. |
required |
origin
|
str
|
Origin date, by default "1958-01-01". |
'1958-01-01'
|
unit
|
str
|
Time unit, by default "us" (microseconds). |
'us'
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Time array in datetime64[ns]. |
Source code in monetio/readers/sat_utils.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
lazy_index_along_axis(data, index, dim)
Index a dimension using another DataArray lazily, handling both Eager and Dask. Fixes the 'vindex does not support indexing with dask objects' limitation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
DataArray to index. Must have dimension |
required |
index
|
DataArray
|
DataArray of indices. |
required |
dim
|
str
|
Dimension name to index along. |
required |
Returns:
| Type | Description |
|---|---|
DataArray
|
The indexed DataArray. |
Source code in monetio/readers/sat_utils.py
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 | |
standardize_satellite_coords(ds, lat_name='Latitude', lon_name='Longitude', y_dim=['Rows', 'scanline', 'nlat', 'lat', 'nscan', 'nTimes'], x_dim=['Columns', 'ground_pixel', 'nlon', 'lon', 'nstep', 'nIFOV'], z_dim=['Levels', 'layer', 'level', 'nLayer'], time_name='Time')
Standardize satellite swath/gridded coordinates and dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Input dataset. |
required |
lat_name
|
str
|
Name of the latitude coordinate in the file, by default "Latitude". |
'Latitude'
|
lon_name
|
str
|
Name of the longitude coordinate in the file, by default "Longitude". |
'Longitude'
|
y_dim
|
str or list of str
|
Name(s) of the y/row dimension in the file, by default ["Rows", "scanline"]. |
['Rows', 'scanline', 'nlat', 'lat', 'nscan', 'nTimes']
|
x_dim
|
str or list of str
|
Name(s) of the x/column dimension in the file, by default ["Columns", "ground_pixel"]. |
['Columns', 'ground_pixel', 'nlon', 'lon', 'nstep', 'nIFOV']
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset with standardized dimensions (y, x) and coordinates (latitude, longitude). |
Source code in monetio/readers/sat_utils.py
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 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 | |
tai93_to_datetime(time_array)
Convert TAI93 time (seconds since 1993-01-01) to datetime64[ns].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_array
|
DataArray
|
Input time array in seconds since 1993-01-01 00:00:00 UTC. |
required |
Returns:
| Type | Description |
|---|---|
DataArray
|
Time array in datetime64[ns]. |
Examples:
>>> ds["time"] = tai93_to_datetime(ds["Scan_Start_Time"])
Source code in monetio/readers/sat_utils.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
update_history(ds, message)
Update the 'history' attribute of a dataset or dataframe backend-agnostic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
xarray.Dataset, xarray.DataArray, pandas.DataFrame, or dask.DataFrame
|
Input object. |
required |
message
|
str
|
Message to add to history. |
required |
Returns:
| Type | Description |
|---|---|
object
|
The input object with updated history. |
Source code in monetio/readers/sat_utils.py
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 290 291 292 293 294 | |