Data Fetcher Module
DataFetcher
Source code in yooink/request/data_fetcher.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 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 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 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 |
|
__init__(username=None, token=None)
Initialize the DatasetFetcher.
Source code in yooink/request/data_fetcher.py
15 16 17 18 19 20 21 22 |
|
filter_urls(site, assembly, instrument, method)
staticmethod
Filters the M2M_URLS dictionary for the instrument of interest.
This function searches for the instrument of interest as defined by the site code, assembly type, instrument class, and data delivery method to return the OOI specific site, node and stream names needed to request the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
site
|
str
|
OOI eight letter site code (e.g. CE04OSPS for the Oregon Offshore Shallow Profiler) |
required |
assembly
|
str
|
Assembly grouping name (e.g. midwater for the 200 m Platform) |
required |
instrument
|
str
|
The instrument class name (e.g. phsen for the SAMI2-pH sensor) |
required |
method
|
str
|
The data delivery method (e.g. streamed for cabled streaming data) |
required |
Returns:
Type | Description |
---|---|
tuple[List[str], List[str], List[str]]
|
A tuple containing three lists: - node: The OOI specific node code(s) for the assembly - sensor: The OOI specific sensor code(s) for the instrument class - stream: The OOI specific stream name(s) for the site, node, sensor and delivery method combination |
Raises:
Type | Description |
---|---|
SyntaxError
|
If an unknown site code or data delivery method is provided. |
RuntimeWarning
|
If the instrument defined by the given parameters cannot be found. |
Source code in yooink/request/data_fetcher.py
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 |
|
get_dataset(site, assembly, instrument, method, **kwargs)
Requests data via the OOI M2M API using the site code, assembly type, instrument class and data delivery method.
This function constructs the OOI specific data request using the parameters defined in the m2m_urls.yml file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
site
|
str
|
OOI site code as an 8 character string |
required |
assembly
|
str
|
The assembly type where the instrument is located |
required |
instrument
|
str
|
The OOI instrument class name for the instrument of interest |
required |
method
|
str
|
The data delivery method for the system of interest |
required |
**kwargs
|
Any
|
Optional keyword arguments: start: Starting date/time for the data request in a dateutil.parser recognizable form. If None, the beginning of the data record will be used. stop: Ending date/time for the data request in a dateutil.parser recognizable form. If None, the end of the data record will be used. deploy: Use the deployment number (integer) to set the starting and ending dates. If None, the starting and ending dates are used. If both are provided, the deployment number takes priority. aggregate: In cases where more than one instance of an instrument class is part of an assembly, will collect all the data if 0, or the specific instance of the instrument if any value greater than 0 is used. If None, the first instance of an instrument will be used. |
{}
|
Returns:
Type | Description |
---|---|
Dataset
|
An xarray dataset containing the requested data for further |
Dataset
|
analysis. |
Raises:
Type | Description |
---|---|
KeyError
|
If an unknown keyword argument is provided. |
SyntaxError
|
If the date string format is unrecognizable or if an invalid aggregate value is provided. |
RuntimeWarning
|
If deployment dates are unavailable or if data is unavailable for the specified parameters. |
Source code in yooink/request/data_fetcher.py
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 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 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 |
|