utils
batch_requested_dates(dates, attribute='month')
TODO: should be using Pandas DatetimeIndexes / Periods for this, but the need to refactor slightly, and this is working for the moment
TODO: we should be yielding from here surely
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dates
|
object
|
|
required |
attribute
|
str
|
|
'month'
|
Returns:
| Type | Description |
|---|---|
object
|
|
Source code in download_toolbox/data/utils.py
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 45 46 47 48 49 50 51 | |
merge_files(new_datafile, other_datafile, drop_variables=None)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_datafile
|
object
|
|
required |
other_datafile
|
object
|
|
required |
drop_variables
|
object
|
|
None
|
Source code in download_toolbox/data/utils.py
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 | |
s3_file_download(bucket_name, key, filename)
Download a file from S3 bucket to local storage.
If the file already exists and matches the expected size, skip download. If the file exists but is incomplete, re-download it.
Args: bucket_name: Name of the S3 bucket. key: Key of the file in the S3 bucket. filename: Local path to save the downloaded file.
Source code in download_toolbox/data/utils.py
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 | |
xr_save_netcdf(da, file_path, complevel=0)
Save xarray Dataarray to netCDF file with optional compression.
Args: da: The xarray dataarray to be output to netCDF. file_path: Path to save the netCDF file. complevel (optional): Level of compression to apply. Defaults to 0.
Source code in download_toolbox/data/utils.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |