Debian Codegraph @

examples/SDO.ipynb

raw
1 {
2 "cells": [
3 {
4 "cell_type": "markdown",
5 "id": "b1679638",
6 "metadata": {},
7 "source": [
8 "# Solar Dynamics Observatory\n",
9 "\n",
10 "Single timeseries of EUV data\n",
11 "\n",
12 "### CASE 1: one chunk per file, timeseries sorted into filter bands. Doesn't need FITS."
13 ]
14 },
15 {
16 "cell_type": "code",
17 "execution_count": null,
18 "id": "9bad6590",
19 "metadata": {},
20 "outputs": [],
21 "source": [
22 "import intake\n",
23 "import hvplot.xarray"
24 ]
25 },
26 {
27 "cell_type": "code",
28 "execution_count": null,
29 "id": "25b832d8",
30 "metadata": {},
31 "outputs": [],
32 "source": [
33 "cat = intake.open_catalog(\"https://github.com/fsspec/kerchunk/raw/main/\"\n",
34 " \"examples/intake_catalog.yml\")"
35 ]
36 },
37 {
38 "cell_type": "code",
39 "execution_count": null,
40 "id": "d9e804ab",
41 "metadata": {},
42 "outputs": [],
43 "source": [
44 "ds = cat.SDO.to_dask()\n",
45 "ds"
46 ]
47 },
48 {
49 "cell_type": "code",
50 "execution_count": null,
51 "id": "3111b1eb",
52 "metadata": {},
53 "outputs": [],
54 "source": [
55 "ds.nbytes / 2**30 # GB"
56 ]
57 },
58 {
59 "cell_type": "markdown",
60 "id": "8e2b74ee",
61 "metadata": {},
62 "source": [
63 "### What just happened?\n",
64 "\n",
65 "Let's look into the detail a little.\n",
66 "\n",
67 "First, where are the files we want:"
68 ]
69 },
70 {
71 "cell_type": "code",
72 "execution_count": null,
73 "id": "8044b8e3",
74 "metadata": {},
75 "outputs": [],
76 "source": [
77 "import fsspec\n",
78 "gcs = fsspec.filesystem(\"gcs\")\n",
79 "gcs.ls(\"pangeo-data/SDO_AIA_Images/\")"
80 ]
81 },
82 {
83 "cell_type": "code",
84 "execution_count": null,
85 "id": "dc8fd986",
86 "metadata": {},
87 "outputs": [],
88 "source": [
89 "gcs.ls(\"pangeo-data/SDO_AIA_Images/094\")[:5]"
90 ]
91 },
92 {
93 "cell_type": "markdown",
94 "id": "fe14433a",
95 "metadata": {},
96 "source": [
97 "Now we create a \"reference\" filesystem:"
98 ]
99 },
100 {
101 "cell_type": "code",
102 "execution_count": null,
103 "id": "3b62679a",
104 "metadata": {},
105 "outputs": [],
106 "source": [
107 "fs = fsspec.filesystem(\n",
108 " \"reference\",\n",
109 " fo=\"gcs://mdtemp/SDO_no_coords.json\",\n",
110 " remote_options={\"token\": \"anon\"},\n",
111 " remote_protocol=\"gcs\",\n",
112 " target_options={\"token\": \"anon\"}\n",
113 ")"
114 ]
115 },
116 {
117 "cell_type": "code",
118 "execution_count": null,
119 "id": "19b1c9e9",
120 "metadata": {},
121 "outputs": [],
122 "source": [
123 "fs.ls(\"\", False)"
124 ]
125 },
126 {
127 "cell_type": "code",
128 "execution_count": null,
129 "id": "ce63dfe6",
130 "metadata": {},
131 "outputs": [],
132 "source": [
133 "fs.ls(\"094\", False)[:5]"
134 ]
135 },
136 {
137 "cell_type": "code",
138 "execution_count": null,
139 "id": "9c9a510d",
140 "metadata": {},
141 "outputs": [],
142 "source": [
143 "print(fs.cat(\"094/.zarray\").decode())"
144 ]
145 },
146 {
147 "cell_type": "code",
148 "execution_count": null,
149 "id": "cf1110b1",
150 "metadata": {},
151 "outputs": [],
152 "source": [
153 "fs.references[\"094/0.0.0\"]"
154 ]
155 },
156 {
157 "cell_type": "markdown",
158 "id": "0bff3d30",
159 "metadata": {},
160 "source": [
161 "### Viz\n",
162 "\n",
163 "So let's see it in action!"
164 ]
165 },
166 {
167 "cell_type": "code",
168 "execution_count": null,
169 "id": "b796814e",
170 "metadata": {},
171 "outputs": [],
172 "source": [
173 "import numpy as np\n",
174 "ds = ds.assign_coords(x=np.arange(4096), y=np.arange(4096))"
175 ]
176 },
177 {
178 "cell_type": "code",
179 "execution_count": null,
180 "id": "1a826fb8",
181 "metadata": {},
182 "outputs": [],
183 "source": [
184 "import numpy as np\n",
185 "ds[\"094\"].hvplot.image(\n",
186 " 'x', 'y', colormap=\"fire\", xaxis=False, yaxis=False, \n",
187 " height=500, width=500, colorbar=False, clim=(0, 50)\n",
188 ")"
189 ]
190 },
191 {
192 "cell_type": "code",
193 "execution_count": null,
194 "id": "db43273d",
195 "metadata": {},
196 "outputs": [],
197 "source": []
198 }
199 ],
200 "metadata": {
201 "kernelspec": {
202 "display_name": "Python 3",
203 "language": "python",
204 "name": "python3"
205 },
206 "language_info": {
207 "codemirror_mode": {
208 "name": "ipython",
209 "version": 3
210 },
211 "file_extension": ".py",
212 "mimetype": "text/x-python",
213 "name": "python",
214 "nbconvert_exporter": "python",
215 "pygments_lexer": "ipython3",
216 "version": "3.8.8"
217 }
218 },
219 "nbformat": 4,
220 "nbformat_minor": 5
221 }