|
28 | 28 | "\n", |
29 | 29 | "The public deployment currently evaluates CMIP6 dataset, but will include CMIP7 Assessment Fast Track data\n", |
30 | 30 | "as they become available.\n", |
31 | | - "Results are served from a website (<https://dashboard.climate-ref.org>) and a public API (<https://api.climate-ref.org>).\n", |
32 | 31 | "\n", |
33 | | - "Throughout these notebooks we talk to the API via an \"SDK\".\n", |
34 | | - "This SDK allows us to make requests to the API without having to directly make HTTP requests.\n", |
35 | | - "The `ref_tutorials` helper package (shipped with this repository) builds the API client for us." |
| 32 | + "The REF has a dashboard (<https://dashboard.climate-ref.org>) which offers a curated view of the results from the REF. \n", |
| 33 | + "This dashboard uses an API (<https://api.climate-ref.org>) to provide access to the results in a structured way.\n", |
| 34 | + "\n", |
| 35 | + "We can use this same API to make our own view of the data. As part of the API we also publish a [schema](https://api.climate-ref.org/docs) that describes the different endpoints that can be queried and the shape of the response" |
| 36 | + ] |
| 37 | + }, |
| 38 | + { |
| 39 | + "cell_type": "markdown", |
| 40 | + "id": "1df88e89", |
| 41 | + "metadata": {}, |
| 42 | + "source": [ |
| 43 | + "Throughout these notebooks we talk to the API via an \"SDK\" which is a small software package generated from the schema of the API.\n", |
| 44 | + "This SDK allows us to make requests to the API as function calls without having to directly make HTTP requests.\n", |
| 45 | + "\n", |
| 46 | + "A small script `scripts/generate_client.sh` shows how to built the SDK.\n", |
| 47 | + "\n", |
| 48 | + "> If you are runnning this on Binder, this has been pre-built for you." |
36 | 49 | ] |
37 | 50 | }, |
38 | 51 | { |
39 | 52 | "cell_type": "code", |
40 | | - "execution_count": 2, |
| 53 | + "execution_count": 7, |
41 | 54 | "id": "05ac27ad", |
42 | 55 | "metadata": {}, |
43 | 56 | "outputs": [ |
|
47 | 60 | "Client(raise_on_unexpected_status=False, _base_url='https://api.climate-ref.org', _cookies={}, _headers={}, _timeout=None, _verify_ssl=True, _follow_redirects=False, _httpx_args={}, _client=None, _async_client=None)" |
48 | 61 | ] |
49 | 62 | }, |
50 | | - "execution_count": 2, |
| 63 | + "execution_count": 7, |
51 | 64 | "metadata": {}, |
52 | 65 | "output_type": "execute_result" |
53 | 66 | } |
|
59 | 72 | "client" |
60 | 73 | ] |
61 | 74 | }, |
| 75 | + { |
| 76 | + "cell_type": "markdown", |
| 77 | + "id": "871f914b", |
| 78 | + "metadata": {}, |
| 79 | + "source": [ |
| 80 | + "## Datasets\n", |
| 81 | + "\n", |
| 82 | + "Datasets containing CMORised climate model output, and the reference data it is compared to are a key input to the REF.\n", |
| 83 | + "The REF tracks which datasets are available and which diagnostics have already been run." |
| 84 | + ] |
| 85 | + }, |
62 | 86 | { |
63 | 87 | "cell_type": "markdown", |
64 | 88 | "id": "19c3c017", |
|
74 | 98 | }, |
75 | 99 | { |
76 | 100 | "cell_type": "code", |
77 | | - "execution_count": 3, |
| 101 | + "execution_count": 8, |
78 | 102 | "id": "8196f36e", |
79 | 103 | "metadata": {}, |
80 | 104 | "outputs": [ |
81 | 105 | { |
82 | 106 | "name": "stdout", |
83 | 107 | "output_type": "stream", |
84 | 108 | "text": [ |
85 | | - "47 diagnostics available\n", |
| 109 | + "47 diagnostics available. Showing the first 10:\n", |
86 | 110 | "\n", |
87 | 111 | " annual-cycle Annual Cycle Analysis\n", |
88 | 112 | " sea-ice-area-basic Arctic and Antarctic Sea Ice Area Seasonal Cycle\n", |
|
101 | 125 | "from climate_ref_client.api.diagnostics import diagnostics_list\n", |
102 | 126 | "\n", |
103 | 127 | "diagnostics = diagnostics_list.sync(client=client).data\n", |
104 | | - "print(f\"{len(diagnostics)} diagnostics available\\n\")\n", |
| 128 | + "print(f\"{len(diagnostics)} diagnostics available. Showing the first 10:\\n\")\n", |
105 | 129 | "for diagnostic in sorted(diagnostics, key=lambda d: d.name)[:10]:\n", |
106 | 130 | " print(f\" {diagnostic.slug:35s} {diagnostic.name}\")" |
107 | 131 | ] |
|
117 | 141 | }, |
118 | 142 | { |
119 | 143 | "cell_type": "code", |
120 | | - "execution_count": 4, |
| 144 | + "execution_count": 9, |
121 | 145 | "id": "3389ca04", |
122 | 146 | "metadata": {}, |
123 | 147 | "outputs": [ |
|
161 | 185 | }, |
162 | 186 | { |
163 | 187 | "cell_type": "code", |
164 | | - "execution_count": 5, |
| 188 | + "execution_count": 10, |
165 | 189 | "id": "45bfc188", |
166 | 190 | "metadata": {}, |
167 | 191 | "outputs": [ |
|
184 | 208 | }, |
185 | 209 | { |
186 | 210 | "cell_type": "markdown", |
187 | | - "id": "871f914b", |
| 211 | + "id": "be0528dc", |
188 | 212 | "metadata": {}, |
189 | 213 | "source": [ |
190 | | - "## Datasets\n", |
| 214 | + "## Execution groups and Executions\n", |
| 215 | + "\n", |
| 216 | + "An **execution** is one run of a diagnostic against one specific group of datasets.\n", |
| 217 | + "This execution has information about the datasets that were used to run it, the diagnostic and the outputs.\n", |
191 | 218 | "\n", |
192 | | - "A diagnostic needs **datasets** to run against: the climate model output under evaluation, and the reference data it is compared to.\n", |
193 | | - "The REF tracks which datasets are available and which diagnostics have already been run.\n", |
| 219 | + "A single diagnostic is typically executed many times on different sets of data.\n", |
| 220 | + "This generally depends what is being calculated, but this is often once per model variant.\n", |
| 221 | + "Each of these subsets is an *execution group*.\n", |
194 | 222 | "\n", |
195 | | - "For the public API we do not handle raw CMIP6 datasets directly the evaluations have already\n", |
196 | | - "been run. We will see locally fetched datasets in notebook 04." |
| 223 | + "Each execution group has a unique key that describes it.\n", |
| 224 | + "If any datasets in an execution group change, then a new execution is performed.\n", |
| 225 | + "\n", |
| 226 | + "We can list the execution groups available for the Global Warming Level diagnostic:" |
197 | 227 | ] |
198 | 228 | }, |
199 | 229 | { |
200 | | - "cell_type": "markdown", |
201 | | - "id": "be0528dc", |
| 230 | + "cell_type": "code", |
| 231 | + "execution_count": 11, |
| 232 | + "id": "fda2000d", |
202 | 233 | "metadata": {}, |
| 234 | + "outputs": [ |
| 235 | + { |
| 236 | + "name": "stdout", |
| 237 | + "output_type": "stream", |
| 238 | + "text": [ |
| 239 | + "Diagnostic: Climate at Global Warming Levels\n", |
| 240 | + "Execution groups: 4\n", |
| 241 | + "Execution group keys: ['cmip6_ssp126', 'cmip6_ssp245', 'cmip6_ssp370', 'cmip6_ssp585']\n" |
| 242 | + ] |
| 243 | + } |
| 244 | + ], |
203 | 245 | "source": [ |
204 | | - "## Executions\n", |
| 246 | + "from climate_ref_client.api.diagnostics import diagnostics_list_execution_groups\n", |
205 | 247 | "\n", |
206 | | - "An **execution** is one run of a diagnostic against one specific group of datasets.\n", |
| 248 | + "execution_groups = diagnostics_list_execution_groups.sync(\n", |
| 249 | + " client=client, provider_slug=example.provider.slug, diagnostic_slug=example.slug\n", |
| 250 | + ").data\n", |
207 | 251 | "\n", |
208 | | - "A single diagnostic is typically executed many times. This generally depends what is being calculated, but this is often once per model variant.\n", |
209 | | - "Each of these individual groups is an *execution group*.\n", |
210 | | - "If any datasets in an execution group change, then a new execution is performed.\n", |
| 252 | + "first_execution_group = execution_groups[0]\n", |
211 | 253 | "\n", |
212 | | - "Here are the execution groups of one diagnostic:" |
| 254 | + "print(f\"Diagnostic: {example.name}\")\n", |
| 255 | + "print(f\"Execution groups: {len(execution_groups)}\")\n", |
| 256 | + "print(f\"Execution group keys: {[eg.key for eg in execution_groups]}\")" |
| 257 | + ] |
| 258 | + }, |
| 259 | + { |
| 260 | + "cell_type": "markdown", |
| 261 | + "id": "dce894b0", |
| 262 | + "metadata": {}, |
| 263 | + "source": [ |
| 264 | + "Within each execution group, there may be multiple executions.\n", |
| 265 | + "For this execution we can access the outputs that were generated as well as a URL for downloading them." |
213 | 266 | ] |
214 | 267 | }, |
215 | 268 | { |
216 | 269 | "cell_type": "code", |
217 | | - "execution_count": 6, |
218 | | - "id": "e06e64b8", |
| 270 | + "execution_count": 12, |
| 271 | + "id": "c0e32afa", |
219 | 272 | "metadata": {}, |
220 | 273 | "outputs": [ |
221 | 274 | { |
222 | 275 | "name": "stdout", |
223 | 276 | "output_type": "stream", |
224 | 277 | "text": [ |
225 | | - "Diagnostic: Climate at Global Warming Levels\n", |
226 | | - "Execution groups: 4\n" |
| 278 | + " executions/recipe_20260305_234552/plots/gwl_mean_plots_pr/plot_gwl_stats/CMIP6_mm_mean_1.5.png https://api.climate-ref.org/api/v1/results/267670\n", |
| 279 | + " executions/recipe_20260305_234552/plots/gwl_mean_plots_pr/plot_gwl_stats/CMIP6_mm_mean_2.0.png https://api.climate-ref.org/api/v1/results/267671\n", |
| 280 | + " executions/recipe_20260305_234552/plots/gwl_mean_plots_pr/plot_gwl_stats/CMIP6_mm_stdev_1.5.png https://api.climate-ref.org/api/v1/results/267672\n", |
| 281 | + " executions/recipe_20260305_234552/plots/gwl_mean_plots_pr/plot_gwl_stats/CMIP6_mm_stdev_2.0.png https://api.climate-ref.org/api/v1/results/267673\n", |
| 282 | + " executions/recipe_20260305_234552/plots/gwl_mean_plots_tas/plot_gwl_stats/CMIP6_mm_mean_1.5.png https://api.climate-ref.org/api/v1/results/267674\n", |
| 283 | + " executions/recipe_20260305_234552/plots/gwl_mean_plots_tas/plot_gwl_stats/CMIP6_mm_mean_2.0.png https://api.climate-ref.org/api/v1/results/267675\n", |
| 284 | + " executions/recipe_20260305_234552/plots/gwl_mean_plots_tas/plot_gwl_stats/CMIP6_mm_stdev_1.5.png https://api.climate-ref.org/api/v1/results/267676\n", |
| 285 | + " executions/recipe_20260305_234552/plots/gwl_mean_plots_tas/plot_gwl_stats/CMIP6_mm_stdev_2.0.png https://api.climate-ref.org/api/v1/results/267677\n", |
| 286 | + " executions/recipe_20260305_234552/work/calculate_gwl_exceedance_years/gwl_exceedance_calculation/GWL_exceedance_years.csv https://api.climate-ref.org/api/v1/results/267678\n", |
| 287 | + " executions/recipe_20260305_234552/work/gwl_mean_plots_pr/plot_gwl_stats/CMIP6_mm_mean_1.5.nc https://api.climate-ref.org/api/v1/results/267679\n", |
| 288 | + " executions/recipe_20260305_234552/work/gwl_mean_plots_pr/plot_gwl_stats/CMIP6_mm_mean_2.0.nc https://api.climate-ref.org/api/v1/results/267680\n", |
| 289 | + " executions/recipe_20260305_234552/work/gwl_mean_plots_pr/plot_gwl_stats/CMIP6_mm_stdev_1.5.nc https://api.climate-ref.org/api/v1/results/267681\n", |
| 290 | + " executions/recipe_20260305_234552/work/gwl_mean_plots_pr/plot_gwl_stats/CMIP6_mm_stdev_2.0.nc https://api.climate-ref.org/api/v1/results/267682\n", |
| 291 | + " executions/recipe_20260305_234552/work/gwl_mean_plots_tas/plot_gwl_stats/CMIP6_mm_mean_1.5.nc https://api.climate-ref.org/api/v1/results/267683\n", |
| 292 | + " executions/recipe_20260305_234552/work/gwl_mean_plots_tas/plot_gwl_stats/CMIP6_mm_mean_2.0.nc https://api.climate-ref.org/api/v1/results/267684\n", |
| 293 | + " executions/recipe_20260305_234552/work/gwl_mean_plots_tas/plot_gwl_stats/CMIP6_mm_stdev_1.5.nc https://api.climate-ref.org/api/v1/results/267685\n", |
| 294 | + " executions/recipe_20260305_234552/work/gwl_mean_plots_tas/plot_gwl_stats/CMIP6_mm_stdev_2.0.nc https://api.climate-ref.org/api/v1/results/267686\n", |
| 295 | + " executions/recipe_20260305_234552/index.html https://api.climate-ref.org/api/v1/results/267687\n" |
227 | 296 | ] |
228 | 297 | } |
229 | 298 | ], |
230 | 299 | "source": [ |
231 | | - "with_executions = next(d for d in diagnostics if d.execution_groups)\n", |
232 | | - "print(f\"Diagnostic: {with_executions.name}\")\n", |
233 | | - "print(f\"Execution groups: {len(with_executions.execution_groups)}\")" |
| 300 | + "for o in first_execution_group.latest_execution.outputs:\n", |
| 301 | + " print(f\" {o.filename:20s} {o.url}\")" |
234 | 302 | ] |
235 | 303 | }, |
236 | 304 | { |
|
0 commit comments