{ "cells": [ { "cell_type": "markdown", "id": "ac074036-9b0f-4c95-817d-e407f2bebc7b", "metadata": {}, "source": [ "### We want to change the getdata api calls from amda url, to speasy library.\n", "\n", "#### First we take a look at how it was done, and what " ] }, { "cell_type": "code", "execution_count": 1, "id": "011e9aa5-2047-431d-810f-28c37652fc77", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "You are requesting sw_v_real outside of its definition range 2023-10-24T01:59:59+00:00>\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "time,temp,pdyn,dens\n", "2023-01-01T00:00:00+00:00,111138.00000,1.68000,2.40000\n", "2023-01-01T01:00:00+00:00,157287.00000,1.74000,2.60000\n", "2023-01-01T02:00:00+00:00,143309.00000,1.72000,2.60000\n", "2023-01-01T03:00:00+00:00,138155.00000,1.57000,2.40000\n", "2023-01-01T04:00:00+00:00,130313.00000,1.68000,2.50000\n", "2023-01-01T05:00:00+00:00,125800.00000,1.58000,2.50000\n", "2023-01-01T06:00:00+00:00,126272.00000,1.35000,2.30000\n", "2023-01-01T07:00:00+00:00,131445.00000,1.28000,2.20000\n", "2023-01-01T08:00:00+00:00,120878.00000,1.43000,2.40000\n", "2023-01-01T09:00:00+00:00,101674.00000,1.44000,2.40000\n", "2023-01-01T10:00:00+00:00,83809.00000,1.29000,2.30000\n", "2023-01-01T11:00:00+00:00,99753.00000,1.40000,2.40000\n", "2023-01-01T12:00:00+00:00,120895.00000,1.38000,2.40000\n", "2023-01-01T13:00:00+00:00,114336.00000,1.54000,2.70000\n", "2023-01-01T14:00:00+00:00,103012.00000,1.46000,2.60000\n", "2023-01-01T15:00:00+00:00,105619.00000,1.38000,2.60000\n", "2023-01-01T16:00:00+00:00,124735.00000,1.42000,2.70000\n", "2023-01-01T17:00:00+00:00,147645.00000,1.59000,2.90000\n", "2023-01-01T18:00:00+00:00,126711.00000,1.61000,3.00000\n", "2023-01-01T19:00:00+00:00,112862.00000,1.55000,2.90000\n", "2023-01-01T20:00:00+00:00,162523.00000,1.82000,3.50000\n", "2023-01-01T21:00:00+00:00,149738.00000,1.39000,2.90000\n", "2023-01-01T22:00:00+00:00,137384.00000,1.44000,3.00000\n", "2023-01-01T23:00:00+00:00,125401.00000,1.47000,3.00000\n", "2023-01-02T00:00:00+00:00,122840.00000,1.53000,3.10000\n", "2023-01-02T01:00:00+00:00,106846.00000,1.46000,3.00000\n", "2023-01-02T02:00:00+00:00,99071.00000,1.46000,3.00000\n", "2023-01-02T03:00:00+00:00,85018.00000,1.28000,2.80000\n", "2023-01-02T04:00:00+00:00,85618.00000,1.51000,3.00000\n", "2023-01-02T05:00:00+00:00,86212.00000,1.32000,2.90000\n", "2023-01-02T06:00:00+00:00,73818.00000,1.19000,2.70000\n", "2023-01-02T07:00:00+00:00,63770.00000,1.12000,2.60000\n", "2023-01-02T08:00:00+00:00,68417.00000,1.12000,2.60000\n", "2023-01-02T09:00:00+00:00,94122.00000,1.47000,3.10000\n", "2023-01-02T10:00:00+00:00,87577.00000,1.35000,3.00000\n", "2023-01-02T11:00:00+00:00,85190.00000,1.25000,3.00000\n", "2023-01-02T12:00:00+00:00,72614.00000,1.40000,3.40000\n", "2023-01-02T13:00:00+00:00,76904.00000,1.54000,3.80000\n", "2023-01-02T14:00:00+00:00,56066.00000,1.24000,3.10000\n", "2023-01-02T15:00:00+00:00,69746.00000,1.28000,3.30000\n", "2023-01-02T16:00:00+00:00,75615.00000,1.49000,4.00000\n", "2023-01-02T17:00:00+00:00,62380.00000,1.50000,4.10000\n", "2023-01-02T18:00:00+00:00,59769.00000,1.62000,4.40000\n", "2023-01-02T19:00:00+00:00,65882.00000,1.73000,4.70000\n", "2023-01-02T20:00:00+00:00,73645.00000,1.62000,4.40000\n", "2023-01-02T21:00:00+00:00,71164.00000,1.65000,4.50000\n", "2023-01-02T22:00:00+00:00,72474.00000,1.59000,4.40000\n", "2023-01-02T23:00:00+00:00,73063.00000,1.54000,4.40000\n", "2023-01-03T00:00:00+00:00,80324.00000,1.60000,4.60000\n", "2023-01-03T01:00:00+00:00,74410.00000,1.39000,4.20000\n", "2023-01-03T02:00:00+00:00,60560.00000,1.40000,4.20000\n", "2023-01-03T03:00:00+00:00,60649.00000,1.23000,3.90000\n", "2023-01-03T04:00:00+00:00,73376.00000,1.27000,3.80000\n", "2023-01-03T05:00:00+00:00,71081.00000,1.20000,3.60000\n", "2023-01-03T06:00:00+00:00,80067.00000,1.26000,3.90000\n", "2023-01-03T07:00:00+00:00,78052.00000,1.24000,3.80000\n", "2023-01-03T08:00:00+00:00,70693.00000,1.26000,3.70000\n", "2023-01-03T09:00:00+00:00,65080.00000,1.16000,3.70000\n", "2023-01-03T10:00:00+00:00,69157.00000,1.24000,4.00000\n", "2023-01-03T11:00:00+00:00,63887.00000,1.22000,4.00000\n", "2023-01-03T12:00:00+00:00,67081.00000,1.15000,3.80000\n", "2023-01-03T13:00:00+00:00,63483.00000,1.09000,3.70000\n", "2023-01-03T14:00:00+00:00,66328.00000,1.29000,4.40000\n", "2023-01-03T15:00:00+00:00,59545.00000,1.41000,4.60000\n", "2023-01-03T16:00:00+00:00,50088.00000,1.45000,4.80000\n", "2023-01-03T17:00:00+00:00,61460.00000,1.66000,5.40000\n", "2023-01-03T18:00:00+00:00,78555.00000,1.78000,5.70000\n", "2023-01-03T19:00:00+00:00,86914.00000,2.30000,7.30000\n", "2023-01-03T20:00:00+00:00,88598.00000,2.55000,7.60000\n", "2023-01-03T21:00:00+00:00,87751.00000,3.00000,8.70000\n", "2023-01-03T22:00:00+00:00,117278.00000,4.23000,11.80000\n", "2023-01-03T23:00:00+00:00,110663.00000,5.01000,13.60000\n", "2023-01-04T00:00:00+00:00,74512.00000,5.13000,14.10000\n", "2023-01-04T01:00:00+00:00,38583.00000,5.36000,14.30000\n", "2023-01-04T02:00:00+00:00,38751.00000,6.46000,17.30000\n", "2023-01-04T03:00:00+00:00,18241.00000,1.86000,5.40000\n", "2023-01-04T04:00:00+00:00,11536.00000,1.06000,3.20000\n", "2023-01-04T05:00:00+00:00,12808.00000,1.19000,3.60000\n", "2023-01-04T06:00:00+00:00,16386.00000,1.09000,3.30000\n", "2023-01-04T07:00:00+00:00,26502.00000,1.71000,5.20000\n", "2023-01-04T08:00:00+00:00,14901.00000,2.48000,7.30000\n", "2023-01-04T09:00:00+00:00,14856.00000,2.34000,7.10000\n", "2023-01-04T10:00:00+00:00,8636.00000,1.81000,5.30000\n", "2023-01-04T11:00:00+00:00,6326.00000,1.55000,4.60000\n", "2023-01-04T12:00:00+00:00,8101.00000,1.25000,3.80000\n", "2023-01-04T13:00:00+00:00,17297.00000,1.68000,4.90000\n", "2023-01-04T14:00:00+00:00,35285.00000,4.00000,12.20000\n", "2023-01-04T15:00:00+00:00,28390.00000,7.83000,25.40000\n", "2023-01-04T16:00:00+00:00,13834.00000,7.74000,23.80000\n", "2023-01-04T17:00:00+00:00,21130.00000,5.25000,16.10000\n", "2023-01-04T18:00:00+00:00,25436.00000,3.89000,11.60000\n", "2023-01-04T19:00:00+00:00,24408.00000,4.42000,13.90000\n", "2023-01-04T20:00:00+00:00,19095.00000,3.79000,12.30000\n", "2023-01-04T21:00:00+00:00,16898.00000,3.21000,10.10000\n", "2023-01-04T22:00:00+00:00,22020.00000,3.52000,11.10000\n", "2023-01-04T23:00:00+00:00,35891.00000,3.81000,11.60000\n", "2023-01-05T00:00:00+00:00,43391.00000,4.14000,12.60000\n", "2023-01-05T01:00:00+00:00,45593.00000,4.23000,12.90000\n", "2023-01-05T02:00:00+00:00,25325.00000,3.59000,11.50000\n", "2023-01-05T03:00:00+00:00,21338.00000,4.11000,13.00000\n", "2023-01-05T04:00:00+00:00,23628.00000,4.51000,14.20000\n", "2023-01-05T05:00:00+00:00,30623.00000,4.60000,14.50000\n", "2023-01-05T06:00:00+00:00,59208.00000,4.63000,17.10000\n", "2023-01-05T07:00:00+00:00,65064.00000,4.95000,18.20000\n", "2023-01-05T08:00:00+00:00,65744.00000,4.96000,17.70000\n", "2023-01-05T09:00:00+00:00,42396.00000,4.07000,14.60000\n", "2023-01-05T10:00:00+00:00,39049.00000,3.81000,14.10000\n", "2023-01-05T11:00:00+00:00,34712.00000,3.30000,12.70000\n", "2023-01-05T12:00:00+00:00,42201.00000,2.49000,10.30000\n", "2023-01-05T13:00:00+00:00,48600.00000,2.95000,12.10000\n", "2023-01-05T14:00:00+00:00,53004.00000,1.71000,7.40000\n", "2023-01-05T15:00:00+00:00,59441.00000,1.83000,8.10000\n", "2023-01-05T16:00:00+00:00,55675.00000,2.21000,9.10000\n", "2023-01-05T17:00:00+00:00,52339.00000,1.97000,8.50000\n", "2023-01-05T18:00:00+00:00,56847.00000,1.81000,7.70000\n", "2023-01-05T19:00:00+00:00,70239.00000,1.82000,7.40000\n", "2023-01-05T20:00:00+00:00,66345.00000,1.55000,6.90000\n", "2023-01-05T21:00:00+00:00,86348.00000,1.28000,6.00000\n", "2023-01-05T22:00:00+00:00,96860.00000,1.09000,5.00000\n", "2023-01-05T23:00:00+00:00,308427.00000,1.20000,4.40000\n", "2023-01-06T00:00:00+00:00,,1.14000,4.40000\n", "2023-01-06T01:00:00+00:00,243193.00000,1.07000,4.10000\n", "2023-01-06T02:00:00+00:00,227973.00000,1.02000,4.20000\n", "2023-01-06T03:00:00+00:00,239434.00000,1.01000,3.90000\n", "2023-01-06T04:00:00+00:00,,0.73000,3.00000\n", "2023-01-06T05:00:00+00:00,207216.00000,0.68000,2.50000\n", "2023-01-06T06:00:00+00:00,153073.00000,0.93000,3.70000\n", "2023-01-06T07:00:00+00:00,197762.00000,0.95000,3.80000\n", "2023-01-06T08:00:00+00:00,115180.00000,0.75000,3.00000\n", "2023-01-06T09:00:00+00:00,155515.00000,0.97000,4.40000\n", "2023-01-06T10:00:00+00:00,125038.00000,0.77000,3.20000\n", "2023-01-06T11:00:00+00:00,83102.00000,0.96000,3.50000\n", "2023-01-06T12:00:00+00:00,236454.00000,1.08000,3.60000\n", "2023-01-06T13:00:00+00:00,185441.00000,0.91000,3.10000\n", "2023-01-06T14:00:00+00:00,128311.00000,0.84000,2.90000\n", "2023-01-06T15:00:00+00:00,94752.00000,0.73000,2.60000\n", "2023-01-06T16:00:00+00:00,159954.00000,0.50000,1.70000\n", "2023-01-06T17:00:00+00:00,214917.00000,0.50000,1.80000\n", "2023-01-06T18:00:00+00:00,220779.00000,0.56000,1.90000\n", "2023-01-06T19:00:00+00:00,185869.00000,0.67000,2.10000\n", "2023-01-06T20:00:00+00:00,112006.00000,1.04000,2.80000\n", "2023-01-06T21:00:00+00:00,183416.00000,1.16000,3.00000\n", "2023-01-06T22:00:00+00:00,251850.00000,1.60000,4.10000\n", "2023-01-06T23:00:00+00:00,216534.00000,1.48000,3.80000\n", "2023-01-07T00:00:00+00:00,171134.00000,1.32000,3.50000\n", "2023-01-07T01:00:00+00:00,131298.00000,1.19000,3.20000\n", "2023-01-07T02:00:00+00:00,111183.00000,1.43000,3.80000\n", "2023-01-07T03:00:00+00:00,92750.00000,1.47000,3.90000\n", "2023-01-07T04:00:00+00:00,103288.00000,1.40000,3.80000\n", "2023-01-07T05:00:00+00:00,109300.00000,1.73000,4.40000\n", "2023-01-07T06:00:00+00:00,84013.00000,1.13000,3.60000\n", "2023-01-07T07:00:00+00:00,69612.00000,1.30000,3.80000\n", "2023-01-07T08:00:00+00:00,46764.00000,1.23000,3.80000\n", "2023-01-07T09:00:00+00:00,50690.00000,1.40000,4.10000\n", "2023-01-07T10:00:00+00:00,72673.00000,1.39000,4.20000\n", "2023-01-07T11:00:00+00:00,67451.00000,1.51000,4.30000\n", "2023-01-07T12:00:00+00:00,55848.00000,1.60000,4.30000\n", "2023-01-07T13:00:00+00:00,66216.00000,1.36000,4.30000\n", "2023-01-07T14:00:00+00:00,57863.00000,1.36000,4.20000\n", "2023-01-07T15:00:00+00:00,77623.00000,1.57000,4.70000\n", "2023-01-07T16:00:00+00:00,77152.00000,1.30000,4.20000\n", "2023-01-07T17:00:00+00:00,80714.00000,1.46000,4.50000\n", "2023-01-07T18:00:00+00:00,81663.00000,1.50000,4.60000\n", "2023-01-07T19:00:00+00:00,93306.00000,1.56000,4.70000\n", "2023-01-07T20:00:00+00:00,76051.00000,1.38000,4.60000\n", "2023-01-07T21:00:00+00:00,102907.00000,1.71000,5.10000\n", "2023-01-07T22:00:00+00:00,100219.00000,1.55000,4.90000\n", "2023-01-07T23:00:00+00:00,96426.00000,1.59000,5.10000\n", "2023-01-08T00:00:00+00:00,104024.00000,1.66000,5.20000\n", "2023-01-08T01:00:00+00:00,100793.00000,1.50000,5.00000\n", "2023-01-08T02:00:00+00:00,99328.00000,1.35000,4.90000\n", "2023-01-08T03:00:00+00:00,,,\n", "2023-01-08T04:00:00+00:00,,,\n", "2023-01-08T05:00:00+00:00,,,\n", "2023-01-08T06:00:00+00:00,,,\n", "2023-01-08T07:00:00+00:00,,,\n", "2023-01-08T08:00:00+00:00,,,\n", "2023-01-08T09:00:00+00:00,,,\n", "2023-01-08T10:00:00+00:00,,,\n", "2023-01-08T11:00:00+00:00,,,\n", "2023-01-08T12:00:00+00:00,,,\n", "2023-01-08T13:00:00+00:00,,,\n", "2023-01-08T14:00:00+00:00,,,\n", "2023-01-08T15:00:00+00:00,76889.00000,1.52000,5.00000\n", "2023-01-08T16:00:00+00:00,82132.00000,1.54000,5.10000\n", "2023-01-08T17:00:00+00:00,64513.00000,1.60000,5.00000\n", "2023-01-08T18:00:00+00:00,,,\n", "2023-01-08T19:00:00+00:00,,,\n", "2023-01-08T20:00:00+00:00,,,\n", "2023-01-08T21:00:00+00:00,,,\n", "2023-01-08T22:00:00+00:00,,,\n", "2023-01-08T23:00:00+00:00,,,\n", "2023-01-09T00:00:00+00:00,,,\n", "2023-01-09T01:00:00+00:00,,,\n", "2023-01-09T02:00:00+00:00,,,\n", "2023-01-09T03:00:00+00:00,,,\n", "2023-01-09T04:00:00+00:00,,,\n", "2023-01-09T05:00:00+00:00,,,\n", "2023-01-09T06:00:00+00:00,,,\n", "2023-01-09T07:00:00+00:00,,,\n", "2023-01-09T08:00:00+00:00,,,\n", "2023-01-09T09:00:00+00:00,,,\n", "2023-01-09T10:00:00+00:00,,,\n", "2023-01-09T11:00:00+00:00,,,\n", "2023-01-09T12:00:00+00:00,34740.00000,1.16000,4.80000\n", "2023-01-09T13:00:00+00:00,36814.00000,1.14000,4.80000\n", "2023-01-09T14:00:00+00:00,49135.00000,1.46000,5.90000\n", "2023-01-09T15:00:00+00:00,46296.00000,1.42000,5.90000\n", "2023-01-09T16:00:00+00:00,37429.00000,1.32000,5.50000\n", "2023-01-09T17:00:00+00:00,34514.00000,1.44000,6.00000\n", "2023-01-09T18:00:00+00:00,32416.00000,1.38000,5.90000\n", "2023-01-09T19:00:00+00:00,25165.00000,1.21000,5.50000\n", "2023-01-09T20:00:00+00:00,33878.00000,1.36000,6.20000\n", "2023-01-09T21:00:00+00:00,28060.00000,1.50000,7.20000\n", "2023-01-09T22:00:00+00:00,24174.00000,1.37000,6.90000\n", "2023-01-09T23:00:00+00:00,21295.00000,1.75000,8.80000\n", "2023-01-10T00:00:00+00:00,51173.00000,2.04000,9.80000\n", "2023-01-10T01:00:00+00:00,64168.00000,2.10000,9.40000\n", "2023-01-10T02:00:00+00:00,65370.00000,2.19000,9.80000\n", "2023-01-10T03:00:00+00:00,68163.00000,2.50000,10.10000\n", "2023-01-10T04:00:00+00:00,81657.00000,2.34000,9.40000\n", "2023-01-10T05:00:00+00:00,97480.00000,2.49000,9.80000\n", "2023-01-10T06:00:00+00:00,88240.00000,2.37000,9.10000\n", "2023-01-10T07:00:00+00:00,85253.00000,2.33000,9.10000\n", "2023-01-10T08:00:00+00:00,98248.00000,2.64000,9.70000\n", "2023-01-10T09:00:00+00:00,110359.00000,2.93000,10.30000\n", "2023-01-10T10:00:00+00:00,107459.00000,2.91000,10.60000\n", "2023-01-10T11:00:00+00:00,124674.00000,2.85000,10.20000\n", "2023-01-10T12:00:00+00:00,124471.00000,2.68000,9.90000\n", "2023-01-10T13:00:00+00:00,125928.00000,2.64000,9.80000\n", "2023-01-10T14:00:00+00:00,139520.00000,2.81000,10.20000\n", "2023-01-10T15:00:00+00:00,133516.00000,2.73000,10.00000\n", "2023-01-10T16:00:00+00:00,113488.00000,2.73000,9.90000\n", "2023-01-10T17:00:00+00:00,79332.00000,2.82000,9.60000\n", "2023-01-10T18:00:00+00:00,110397.00000,2.95000,10.60000\n", "2023-01-10T19:00:00+00:00,122736.00000,2.69000,9.80000\n", "2023-01-10T20:00:00+00:00,116069.00000,2.38000,8.50000\n", "2023-01-10T21:00:00+00:00,119499.00000,2.57000,8.90000\n", "2023-01-10T22:00:00+00:00,125759.00000,2.57000,8.60000\n", "2023-01-10T23:00:00+00:00,132585.00000,2.48000,8.60000\n", "2023-01-11T00:00:00+00:00,149726.00000,2.73000,8.90000\n", "2023-01-11T01:00:00+00:00,139981.00000,2.34000,8.00000\n", "2023-01-11T02:00:00+00:00,140606.00000,2.17000,7.50000\n", "2023-01-11T03:00:00+00:00,166152.00000,2.66000,8.80000\n", "2023-01-11T04:00:00+00:00,156990.00000,2.83000,9.00000\n", "2023-01-11T05:00:00+00:00,148898.00000,2.65000,8.70000\n", "2023-01-11T06:00:00+00:00,145602.00000,2.46000,8.20000\n", "2023-01-11T07:00:00+00:00,125822.00000,2.42000,8.40000\n", "2023-01-11T08:00:00+00:00,130885.00000,2.57000,8.50000\n", "2023-01-11T09:00:00+00:00,140555.00000,2.50000,8.30000\n", "2023-01-11T10:00:00+00:00,147331.00000,2.63000,8.50000\n", "2023-01-11T11:00:00+00:00,135648.00000,2.42000,8.10000\n", "2023-01-11T12:00:00+00:00,128223.00000,2.30000,7.90000\n", "2023-01-11T13:00:00+00:00,130145.00000,2.43000,8.30000\n", "2023-01-11T14:00:00+00:00,123464.00000,1.92000,7.00000\n", "2023-01-11T15:00:00+00:00,134029.00000,2.06000,7.20000\n", "2023-01-11T16:00:00+00:00,128560.00000,2.24000,7.60000\n", "2023-01-11T17:00:00+00:00,100017.00000,2.18000,7.30000\n", "2023-01-11T18:00:00+00:00,89420.00000,2.04000,7.00000\n", "2023-01-11T19:00:00+00:00,112959.00000,2.33000,7.50000\n", "2023-01-11T20:00:00+00:00,129899.00000,2.40000,7.80000\n", "2023-01-11T21:00:00+00:00,117741.00000,2.36000,7.60000\n", "2023-01-11T22:00:00+00:00,118447.00000,2.54000,7.90000\n", "2023-01-11T23:00:00+00:00,116496.00000,2.63000,7.90000\n", "2023-01-12T00:00:00+00:00,107811.00000,2.53000,7.80000\n", "2023-01-12T01:00:00+00:00,114139.00000,2.78000,8.30000\n", "2023-01-12T02:00:00+00:00,125083.00000,2.85000,8.50000\n", "2023-01-12T03:00:00+00:00,136935.00000,2.81000,8.20000\n", "2023-01-12T04:00:00+00:00,137167.00000,2.82000,8.20000\n", "2023-01-12T05:00:00+00:00,146642.00000,2.48000,7.90000\n", "2023-01-12T06:00:00+00:00,127479.00000,2.26000,7.40000\n", "2023-01-12T07:00:00+00:00,94533.00000,2.58000,7.70000\n", "2023-01-12T08:00:00+00:00,92715.00000,2.73000,7.80000\n", "2023-01-12T09:00:00+00:00,86942.00000,2.53000,7.30000\n", "2023-01-12T10:00:00+00:00,88512.00000,2.71000,7.70000\n", "2023-01-12T11:00:00+00:00,106365.00000,2.85000,8.30000\n", "2023-01-12T12:00:00+00:00,110542.00000,3.28000,9.40000\n", "2023-01-12T13:00:00+00:00,112312.00000,3.60000,10.00000\n", "2023-01-12T14:00:00+00:00,112199.00000,3.51000,10.00000\n", "2023-01-12T15:00:00+00:00,100615.00000,3.08000,9.00000\n", "2023-01-12T16:00:00+00:00,98585.00000,2.81000,8.50000\n", "2023-01-12T17:00:00+00:00,87586.00000,2.39000,7.80000\n", "2023-01-12T18:00:00+00:00,91768.00000,2.67000,8.40000\n", "2023-01-12T19:00:00+00:00,89880.00000,2.35000,7.80000\n", "2023-01-12T20:00:00+00:00,84451.00000,2.23000,7.50000\n", "2023-01-12T21:00:00+00:00,73791.00000,1.99000,6.90000\n", "2023-01-12T22:00:00+00:00,78495.00000,2.09000,7.30000\n", "2023-01-12T23:00:00+00:00,92720.00000,2.46000,8.40000\n", "2023-01-13T00:00:00+00:00,98209.00000,2.70000,9.00000\n", "2023-01-13T01:00:00+00:00,86220.00000,2.53000,8.60000\n", "2023-01-13T02:00:00+00:00,80266.00000,2.01000,7.60000\n", "2023-01-13T03:00:00+00:00,54923.00000,1.89000,7.40000\n", "2023-01-13T04:00:00+00:00,36081.00000,1.51000,5.90000\n", "2023-01-13T05:00:00+00:00,24879.00000,1.53000,5.70000\n", "2023-01-13T06:00:00+00:00,44570.00000,1.22000,4.40000\n", "2023-01-13T07:00:00+00:00,71030.00000,1.04000,3.70000\n", "2023-01-13T08:00:00+00:00,80864.00000,1.16000,3.80000\n", "2023-01-13T09:00:00+00:00,60083.00000,0.95000,3.20000\n", "2023-01-13T10:00:00+00:00,42510.00000,1.18000,4.30000\n", "2023-01-13T11:00:00+00:00,31796.00000,1.30000,4.70000\n", "2023-01-13T12:00:00+00:00,79984.00000,1.20000,4.70000\n", "2023-01-13T13:00:00+00:00,77594.00000,1.21000,4.90000\n", "2023-01-13T14:00:00+00:00,81619.00000,1.46000,5.40000\n", "2023-01-13T15:00:00+00:00,87476.00000,1.52000,6.00000\n", "2023-01-13T16:00:00+00:00,82187.00000,1.56000,6.00000\n", "2023-01-13T17:00:00+00:00,104372.00000,1.65000,6.20000\n", "2023-01-13T18:00:00+00:00,95472.00000,2.39000,8.10000\n", "2023-01-13T19:00:00+00:00,87692.00000,3.31000,9.90000\n", "2023-01-13T20:00:00+00:00,72398.00000,2.77000,8.50000\n", "2023-01-13T21:00:00+00:00,145957.00000,2.08000,5.30000\n", "2023-01-13T22:00:00+00:00,338138.00000,2.92000,6.40000\n", "2023-01-13T23:00:00+00:00,377914.00000,2.53000,5.90000\n", "2023-01-14T00:00:00+00:00,379656.00000,2.21000,4.80000\n", "2023-01-14T01:00:00+00:00,392900.00000,1.98000,4.40000\n", "2023-01-14T02:00:00+00:00,302821.00000,1.68000,3.40000\n", "2023-01-14T03:00:00+00:00,250054.00000,1.43000,2.90000\n", "2023-01-14T04:00:00+00:00,224182.00000,1.28000,2.70000\n", "2023-01-14T05:00:00+00:00,240591.00000,1.25000,2.50000\n", "2023-01-14T06:00:00+00:00,273379.00000,1.43000,2.70000\n", "2023-01-14T07:00:00+00:00,375335.00000,1.30000,2.30000\n", "2023-01-14T08:00:00+00:00,343390.00000,1.08000,2.10000\n", "2023-01-14T09:00:00+00:00,260384.00000,1.01000,2.40000\n", "2023-01-14T10:00:00+00:00,199590.00000,0.94000,2.20000\n", "2023-01-14T11:00:00+00:00,175235.00000,0.85000,2.20000\n", "2023-01-14T12:00:00+00:00,147668.00000,0.98000,2.40000\n", "2023-01-14T13:00:00+00:00,123656.00000,0.81000,2.00000\n", "2023-01-14T14:00:00+00:00,111021.00000,0.70000,1.80000\n", "2023-01-14T15:00:00+00:00,101179.00000,0.90000,2.40000\n", "2023-01-14T16:00:00+00:00,78919.00000,0.74000,2.10000\n", "2023-01-14T17:00:00+00:00,57019.00000,0.62000,1.70000\n", "2023-01-14T18:00:00+00:00,64542.00000,0.78000,1.80000\n", "2023-01-14T19:00:00+00:00,73250.00000,0.84000,2.20000\n", "2023-01-14T20:00:00+00:00,44780.00000,0.98000,2.80000\n", "2023-01-14T21:00:00+00:00,54739.00000,1.07000,3.20000\n", "2023-01-14T22:00:00+00:00,68625.00000,1.36000,3.90000\n", "2023-01-14T23:00:00+00:00,59533.00000,1.24000,3.70000\n", "\n" ] } ], "source": [ "import os\n", "import sys\n", "import logging\n", "import matplotlib.pyplot as plt\n", "from datetime import datetime\n", "from speasy import amda\n", "import pandas as pd\n", "from pprint import pprint\n", "\n", "\n", "#\n", "# Heliopropa imports\n", "#\n", "\n", "# try to tweak the logging system first\n", "#\n", "os.environ['DEBUG'] = '0'\n", "\n", "sys.path.insert(0, os.path.abspath('..'))\n", "from web.run import get_target_config,\\\n", " get_data_for_target,\\\n", " FILE_DATE_FMT,\\\n", " generate_csv_contents,\\\n", " generate_csv_contents_spz,\\\n", " init_console_logger\n", "\n", "init_console_logger()\n", "earth_content = generate_csv_contents_spz('earth', 'om', '20230101', '20230115')\n", "print(earth_content)" ] }, { "cell_type": "markdown", "id": "f3df7573-9d30-4f08-a9d1-5040466387df", "metadata": {}, "source": [ "##### Configure dates targets and inputs" ] }, { "cell_type": "code", "execution_count": 2, "id": "b38c421f-b879-4b39-a504-0667a9930aff", "metadata": {}, "outputs": [], "source": [ "# \n", "_target_slug = \"jupiter\"\n", "_input_slug = \"om\"\n", "_start_time = datetime.strptime('20230101', '%Y%m%d')\n", "_stop_time = datetime.strptime('20230401', '%Y%m%d')" ] }, { "cell_type": "markdown", "id": "56b4d003-fc08-4351-a68d-96abec9787da", "metadata": {}, "source": [ "##### Get data with old method (amda http requests)\n", "\n", "Returns dictionnary of tupples indexed by dates.\n", "Each tuple contains 10 values:\n", "\n", "\n", "time,vrad,vtan,vtot,btan,temp,pdyn,dens,atse,xhee,yhee" ] }, { "cell_type": "code", "execution_count": 3, "id": "f580de31-734f-47c2-a09e-c44cbe465a0d", "metadata": {}, "outputs": [], "source": [ "target_config = get_target_config( _target_slug)\n", "all_data = get_data_for_target(target_config, _input_slug, _start_time, _stop_time )" ] }, { "cell_type": "code", "execution_count": 4, "id": "885d8f5e-6632-4f7c-9242-548ba475662c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2023-01-01T00 (418.201, 1.91232, 418.2053547600748, -1.28504, 21.042585, 0.189691, 0.649458, 73.5269, 0.19168941175309254, -4.946060186087171)\n", "2023-01-01T01 (427.381, 2.00023, 427.3856937825598, -1.42265, 23.80293, 0.221789, 0.727082, 73.6145, 0.18835391411799504, -4.946187857748381)\n", "2023-01-01T02 (426.966, 1.80149, 426.96981011542255, -1.36174, 24.530518, 0.214035, 0.70303, 73.7011, 0.18501833890839703, -4.946313278663125)\n", "2023-01-01T03 (425.964, 0.965016, 425.965080728456, -1.25969, 25.500776, 0.200314, 0.661068, 73.7923, 0.1816826873197642, -4.946436448571691)\n", "2023-01-01T04 (425.124, -0.2761, 425.1240811516092, -1.19995, 26.148018, 0.188949, 0.626032, 73.8916, 0.17834696051856475, -4.946557367267161)\n" ] } ], "source": [ "# display first elements of the all_data retrieved this way\n", "small_data_keys = list(all_data.keys())[0:5]\n", "for k in small_data_keys:\n", " # dont display first tuple element that is date\n", " print(k, all_data[k][1:])" ] }, { "cell_type": "code", "execution_count": 5, "id": "ef11af95-c667-4e43-b1ea-cbb31caf3471", "metadata": {}, "outputs": [], "source": [ "# same with the calling method\n", "all_csv = generate_csv_contents(_target_slug, _input_slug, _start_time, _stop_time)\n" ] }, { "cell_type": "code", "execution_count": 6, "id": "7c1a7e1e-dc0c-4b1a-b91e-847788594acd", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['time,vrad,vtan,vtot,btan,temp,pdyn,dens,atse,xhee,yhee\\r', '2023-01-01T00:00:00+00:00,418.201,1.91232,418.2053547600748,-1.28504,21.042585,0.189691,0.649458,73.5269,0.19168941175309254,-4.946060186087171\\r', '2023-01-01T01:00:00+00:00,427.381,2.00023,427.3856937825598,-1.42265,23.80293,0.221789,0.727082,73.6145,0.18835391411799504,-4.946187857748381\\r', '2023-01-01T02:00:00+00:00,426.966,1.80149,426.96981011542255,-1.36174,24.530518,0.214035,0.70303,73.7011,0.18501833890839703,-4.946313278663125\\r', '2023-01-01T03:00:00+00:00,425.964,0.965016,425.965080728456,-1.25969,25.500776,0.200314,0.661068,73.7923,0.1816826873197642,-4.946436448571691\\r', '2023-01-01T04:00:00+00:00,425.124,-0.2761,425.1240811516092,-1.19995,26.148018,0.188949,0.626032,73.8916,0.17834696051856475,-4.946557367267161\\r', '2023-01-01T05:00:00+00:00,423.918,-0.98903,423.91915871425294,-1.18127,26.011208,0.182437,0.607898,73.9947,0.17501115965008188,-4.946676034598966\\r', '2023-01-01T06:00:00+00:00,422.428,-1.23374,422.42980186061686,-1.19154,25.33793,0.179517,0.602393,74.0981,0.17167528584658295,-4.9467924504753285\\r', '2023-01-01T07:00:00+00:00,420.961,-1.24559,420.96282867374407,-1.25493,23.961723,0.179086,0.605142,74.2005,0.1683393402357727,-4.946906614864552\\r', '2023-01-01T08:00:00+00:00,419.637,-1.0635,419.6383301427552,-1.37532,21.373276,0.182003,0.618888,74.3015,0.16500332394941092,-4.947018527795114\\r', '2023-01-01T09:00:00+00:00,418.925,-0.443971,418.9252245329708,-1.49301,18.073362,0.187551,0.639926,74.4034,0.1616672381319541,-4.947128189354561\\r', '2023-01-01T10:00:00+00:00,418.848,0.28136,418.848085527438,-1.55071,14.993965,0.197787,0.6751,74.5078,0.15833108394903567,-4.947235599687129\\r', '2023-01-01T11:00:00+00:00,419.019,0.834926,419.0198570772034,-1.56371,12.125517,0.215581,0.735231,74.612,0.1549948625956068,-4.947340758990131\\r', '2023-01-01T12:00:00+00:00,418.821,1.31839,418.82309063613,-1.55687,9.808448,0.238362,0.813691,74.7163,0.1516585753035288,-4.9474436675091304\\r', '2023-01-01T13:00:00+00:00,417.987,1.76892,417.9907295622715,-1.54465,8.2302065,0.259036,0.88779,74.8197,0.14832222334842712,-4.947544325531972\\r']\n" ] } ], "source": [ "all_csv_aslist = all_csv.split('\\n')\n", "print(all_csv_aslist[0:15])" ] }, { "cell_type": "markdown", "id": "9748ab9f-3dc8-4b02-bf4f-a750a35864b5", "metadata": {}, "source": [ "#### Now rewrite that with speazy\n", "\n", "ie, generate a csv file with that new library.p\n", "That means getting parameters, rename the column as expected by the javascript grappher,\n", "and concatenate to get a single dataframe." ] }, { "cell_type": "code", "execution_count": 7, "id": "05e8cec5-be4e-4a8a-b73c-469cc946ad05", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Orbit dataset : jupiter-orb-all\n", "Plsama dataset : tao-jup-sw\n" ] } ], "source": [ "# First, get the dataset ids \n", "target_config = get_target_config(_target_slug)\n", "orbit_dataset_id = target_config['orbit']['models'][0]['slug']\n", "plasma_dataset_id = target_config['models'][_input_slug][0]['slug']\n", "orbit_dataset_id = orbit_dataset_id.replace('_', '-')\n", "plasma_dataset_id = plasma_dataset_id.replace('_', '-')\n", "\n", "print(f\"Orbit dataset : {orbit_dataset_id}\")\n", "print(f\"Plsama dataset : {plasma_dataset_id}\")\n" ] }, { "cell_type": "code", "execution_count": 8, "id": "af1b616b-d6e0-4ad5-baeb-cce3b9b96fd3", "metadata": {}, "outputs": [], "source": [ "# Then the dataset associated\n", "orbit_dataset = amda.get_dataset(orbit_dataset_id, _start_time, _stop_time)\n", "plasma_dataset = amda.get_dataset(plasma_dataset_id, _start_time, _stop_time)" ] }, { "cell_type": "code", "execution_count": 9, "id": "e6ea5f1a-aeee-42c6-b031-a69466064333", "metadata": {}, "outputs": [], "source": [ "# vrad, vtan, vtot, btan, brad, pdyn, dens, atse, xhee, yhee\n", "\n", "# set a dict of amda parameters ids index by the expected column names in the csv\n", "\n", "params_dict = {'dens': 'mars_sw_n',\n", " 'xy_v': 'mars_sw_v',\n", " 'temp': 'mars_sw_t',\n", " 'pdyn': 'mars_sw_pdyn',\n", " 'btan': 'mars_sw_b',\n", " 'brad': 'mars_sw_bx',\n", " 'atse': 'mars_sw_da',\n", " 'xy_hee': 'xyz_mars_hee'}\n", "\n", "list_df = []\n", "for _name, _id in params_dict.items():\n", " _df = amda.get_data(_id, _start_time, _stop_time).to_dataframe()\n", " if _name == 'xy_v':\n", " _df = _df.rename(columns={_df.columns[0]:'vrad', _df.columns[1]:'vtan'})\n", " elif _name == 'xy_hee':\n", " _df = _df.drop(_df.columns[2], axis=1)\n", " _df = _df.rename(columns={_df.columns[0]:'xhee', _df.columns[1]:'yhee'})\n", " else:\n", " _df = _df.rename(columns={_df.columns[0]: _name})\n", "\n", " # _df = _df[~_df.index.duplicated()]\n", "\n", " # resample to frequency, for later concatenation\n", " _df = _df.resample('1H').mean()\n", "\n", " # _df = _df.loc[_df.first_valid_index():_df.last_valid_index()]\n", "\n", " list_df.append( _df)\n", "\n" ] }, { "cell_type": "code", "execution_count": 10, "id": "8696bcec-5d54-411a-ad9f-8b161f00556b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " vrad vtan vtot btan brad \\\n", "2023-01-01 00:00:00 458.539 -8.99439 458.627205 -1.892408 0.490593 \n", "2023-01-01 01:00:00 539.666 -18.05740 539.968019 -2.591060 2.102028 \n", "2023-01-01 02:00:00 543.801 -16.74380 544.058712 -2.522670 2.062160 \n", "2023-01-01 03:00:00 547.864 -13.52640 548.030953 -2.502990 2.061292 \n", "2023-01-01 04:00:00 549.258 -4.20118 549.274067 -2.487440 2.053632 \n", "\n", " temp pdyn dens atse xhee yhee \n", "2023-01-01 00:00:00 6.42018 0.713528 2.027965 10.3768 1.528606 -0.330547 \n", "2023-01-01 01:00:00 10.00060 0.721630 1.482050 10.6671 1.528529 -0.331140 \n", "2023-01-01 02:00:00 9.38966 0.655797 1.326660 10.6880 1.528452 -0.331733 \n", "2023-01-01 03:00:00 8.68052 0.638148 1.272310 10.7095 1.528375 -0.332326 \n", "2023-01-01 04:00:00 7.80526 0.629647 1.249690 10.7316 1.528297 -0.332920 \n" ] } ], "source": [ "from math import sqrt\n", "final_df = pd.concat(list_df, axis=1)\n", "# Is ther a vtot param ? else build it\n", "if 'vtot' not in final_df.columns:\n", " final_df['vtot'] = final_df.apply(lambda x: sqrt(x.vtan*x.vtan+ x.vrad*x.vrad), axis=1)\n", "\n", "cols_ordered = ['vrad', 'vtan', 'vtot', 'btan', 'brad', 'temp', 'pdyn', 'dens', 'atse', 'xhee', 'yhee']\n", "final_df = final_df[cols_ordered]\n", "\n", "# and show\n", "pd.set_option('display.max_columns', None)\n", "print(final_df.head())" ] }, { "cell_type": "code", "execution_count": 11, "id": "eaec4f41-2524-4562-935a-42b4ce3fdae0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "time\n" ] } ], "source": [ "final_df.index.name = 'time'\n", "print(final_df.index.name)" ] }, { "cell_type": "markdown", "id": "bde656ba-98b9-4b03-93a3-c0121be49388", "metadata": {}, "source": [ "#### Use config to get the parameters dict and send to new method\n" ] }, { "cell_type": "code", "execution_count": 12, "id": "f92a9195-c863-48e4-ae62-2b3adcd66143", "metadata": {}, "outputs": [], "source": [ "def generate_csv_content_spz(target_slug, input_slug, started_at, stopped_at):\n", " target_config = get_target_config(target_slug)\n", " params_dict = target_config['models'][input_slug][0]['parameters']\n", " \n", " list_df = []\n", " for _name, _id in params_dict.items():\n", " _df = amda.get_data(_id, _start_time, _stop_time).to_dataframe()\n", " if _name == 'xy_v':\n", " _df = _df.rename(columns={_df.columns[0]:'vrad', _df.columns[1]:'vtan'})\n", " elif _name == 'xy_hee':\n", " _df = _df.drop(_df.columns[2], axis=1)\n", " _df = _df.rename(columns={_df.columns[0]:'xhee', _df.columns[1]:'yhee'})\n", " else:\n", " _df = _df.rename(columns={_df.columns[0]: _name})\n", " \n", " # _df = _df[~_df.index.duplicated()]\n", " \n", " # resample to frequency, for later concatenation\n", " _df = _df.resample('1H').mean()\n", " \n", " # _df = _df.loc[_df.first_valid_index():_df.last_valid_index()]\n", " \n", " list_df.append( _df)\n", " \n", " from math import sqrt\n", " final_df = pd.concat(list_df, axis=1)\n", " # Is ther a vtot param ? else build it\n", " if 'vtot' not in final_df.columns:\n", " final_df['vtot'] = final_df.apply(lambda x: sqrt(x.vtan*x.vtan+ x.vrad*x.vrad), axis=1)\n", " \n", " \n", " cols_ordered = ['vrad', 'vtan', 'vtot', 'btan', 'brad', 'temp', 'pdyn', 'dens', 'atse', 'xhee', 'yhee']\n", " final_df = final_df[cols_ordered]\n", " final_df.index.name = 'time'\n", " return final_df.to_csv(date_format='%Y-%m-%dT%H:%M:%S', float_format=\"%.5f\",\n", " header=True,\n", " sep=\",\")\n" ] }, { "cell_type": "code", "execution_count": 13, "id": "434bbf7b-d201-4d72-aac5-2a3cac6a3967", "metadata": {}, "outputs": [], "source": [ "ch = logging.StreamHandler()\n", "ch.setLevel(logging.DEBUG)\n", "formatter = logging.Formatter('%(levelname)s-%(message)s')\n", "ch.setFormatter(formatter)\n", "_hp_logger = logging.getLogger(\"HelioPropa\")\n", "_hp_logger.addHandler(ch)" ] }, { "cell_type": "code", "execution_count": 14, "id": "c995ca1c-dc2e-4c0b-95fa-aab394a8cf2c", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO-Aggregating dataframes speazy parameters for 'om' to 'mars'\n", "DEBUG-Getting parameter id 'mars_sw_n' for 'dens'\n", "DEBUG-Getting parameter id 'mars_sw_v' for 'xy_v'\n", "DEBUG-Getting parameter id 'mars_sw_t' for 'temp'\n", "DEBUG-Getting parameter id 'mars_sw_pdyn' for 'pdyn'\n", "DEBUG-Getting parameter id 'mars_sw_b' for 'btan'\n", "DEBUG-Getting parameter id 'mars_sw_bx' for 'brad'\n", "DEBUG-Getting parameter id 'mars_sw_da' for 'atse'\n", "DEBUG-Getting parameter id 'xyz_mars_hee' for 'xy_hee'\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "time,vrad,vtan,vtot,btan,brad,temp,pdyn,dens,atse,xhee,yhee\n", "2023-01-01T00:00:00+00:00,458.53900,-8.99439,458.62721,-1.89241,0.49059,6.42018,0.71353,2.02797,10.37680,1.52861,-0.33055\n", "2023-01-01T01:00:00+00:00,539.66600,-18.05740,539.96802,-2.59106,2.10203,10.00060,0.72163,1.48205,10.66710,1.52853,-0.33114\n", "2023-01-01T02:00:00+00:00,543.80100,-16.74380,544.05871,-2.52267,2.06216,9.38966,0.65580,1.32666,10.68800,1.52845,-0.33173\n", "2023-01-01T03:00:00+00:00,547.86400,-13.52640,548.03095,-2.50299,2.06129,8.68052,0.63815,1.27231,10.70950,1.52837,-0.33233\n", "2023-01-01T04:00:00+00:00,549.25800,-4.20118,549.27407,-2.48744,2.05363,7.80526,0.62965,1.24969,10.73160,1.52830,-0.33292\n", "2023-01-01T05:00:00+00:00,548.67600,5.81362,548.70680,-2.46739,2.03485,6.73197,0.64252,1.27788,10.75300,1.52822,-0.33351\n", "2023-01-01T06:00:00+00:00,546.76300,8.89294,546.83532,-2.38355,1.95879,6.23209,0.62952,1.26060,10.77400,1.52814,-0.33411\n", "2023-01-01T07:00:00+00:00,548.76000,8.77561,548.83016,-2.44846,2.01942,6.44499,0.66720,1.32637,10.79620,1.52806,-0.33470\n", "2023-01-01T08:00:00+00:00,568.55900,5.35430,568.58421,-3.28875,2.81024,8.80241,1.03575,1.91845,10.81750,1.52798,-0.33529\n", "2023-01-01T09:00:00+00:00,575.19300,3.52090,575.20378,-3.97863,3.43930,9.53319,1.20380,2.17869,10.83690,1.52791,-0.33589\n", "2023-01-01T10:00:00+00:00,572.05100,3.21963,572.06006,-4.17327,3.58773,9.32707,1.12910,2.06602,10.85580,1.52783,-0.33648\n", "2023-01-01T11:00:00+00:00,570.28400,1.84143,570.28697,-4.29914,3.68440,9.75793,1.05895,1.94971,10.87520,1.52775,-0.33707\n", "2023-01-01T12:00:00+00:00,571.52000,-4.19166,571.53537,-4.30552,3.69775,11.64290,1.05794,1.93936,10.89480,1.52767,-0.33767\n", "2023-01-01T13:00:00+00:00,571.01300,-7.97585,571.06870,-4.19236,3.59725,13.51050,1.06096,1.94808,10.91470,1.52759,-0.33826\n" ] } ], "source": [ "csv_content = generate_csv_contents_spz('mars', 'om', '20230101', '20230115')\n", "for _l in csv_content.split('\\n')[:15]:\n", " print(_l)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.4" } }, "nbformat": 4, "nbformat_minor": 5 }