Compute the trend of a time series
Let’s perform a linear regression on time series data by exploiting PyOphidia, numpy and matplotlib for the visualization. The goal is to extract the trend of the time series.
1- First of all import the PyOphidia modules and connect to the server-side
[11]:
from PyOphidia import cube
cube.Cube.setclient(read_env=True)
Current cdd is /home/ecasuser
Current session is https://ophidialab.cmcc.it/ophidia/sessions/28428206836738622831574257875438385/experiment
Current cwd is /
The last produced cube is https://ophidialab.cmcc.it/ophidia/6256/850343
2- Load the tasmin variable from the input dataset located at /public/data/ecas_training/tasmin_day_CMCC-CESM_rcp85_r1i1p1_20960101-21001231.nc. The data is imported so that it is time-array oriented.
[12]:
mintemp = cube.Cube.importnc(
src_path='/public/data/ecas_training/tasmin_day_CMCC-CESM_rcp85_r1i1p1_20960101-21001231.nc',
measure='tasmin',
import_metadata='yes',
imp_dim='time',
imp_concept_level='d', vocabulary='CF',hierarchy='oph_base|oph_base|oph_time',
ncores=2,
description='Min Temps')
3- Extract a single time series from the imported cube (just consider the first index for latitute and longitude) and print its content
[13]:
singleTS = mintemp.subset(
subset_dims="lat|lon",
subset_filter="1|1",
subset_type='index',
ncores=2)
singleTS.explore()
tasmin
------
+============+==========+==============================================================================================+
| lat | lon | tasmin |
+============+==========+==============================================================================================+
| -87.159095 | 0.000000 | 255.3484649658, 256.5523071289, 257.9611206055, 258.1882934570, 258.6824951172, 258.75317382 |
| | | 81, 259.7331542969, 259.6237487793, 257.0916748047, 255.5845642090, 256.6911926270, 257.7592 |
| | | 773438, 256.3059692383, 255.1929779053, 254.8903198242, 254.4397430420, 254.0504760742, 255. |
| | | 5076904297, 257.9510498047, 256.1823730469, 255.6322479248, 255.7233581543, 254.8574829102, |
| | | 253.6629943848, 252.9137115479, 251.5997924805, 251.6222076416, 251.5493774414, 250.30424499 |
| | | 51, 251.1147460938, 251.9926452637, 251.3189544678, 251.7014160156, 252.4320526123, 252.2970 |
| | | 123291, 251.1716461182, 250.4209136963, 248.3032226562, 246.7799987793, 248.4742431641, 249. |
| | | 5222930908, 249.5259704590, 249.3989105225, 249.1190185547, 248.5693817139, 245.5846557617, |
| | | 244.1446533203, 244.8745574951, 244.9522552490, 246.5154113770, 244.9841156006, 243.94148254 |
| | | 39, 244.8415679932, 243.8197784424, 242.0131988525, 240.2400360107, 239.8469238281, 240.3424 |
| | | 377441, 239.6099853516, 238.2871704102, 237.5207061768, 236.6348876953, 237.4197235107, 235. |
| | | 5880126953, 234.6139221191, 234.8813476562, 234.2736358643, 232.5729522705, 231.9033660889, |
| | | 231.4647827148, 231.2313995361, 232.7979125977, 235.8311462402, 238.0995483398, 238.75064086 |
| | | 91, 239.3772888184, 238.3493499756, 238.1426544189, 238.4137573242, 235.7441864014, 235.3983 |
| | | 001709, 238.6050567627, 239.7922058105, 235.7785949707, 234.5288238525, 233.3342590332, 233. |
| | | 3254394531, 235.3250427246, 237.0485687256, 238.1914825439, 237.1532745361, 237.3069152832, |
| | | 234.9630279541, 233.8472747803, 231.8538208008, 231.5819091797, 232.9063720703, 233.76841735 |
| | | 84, 233.1745300293, 233.0965576172, 233.0988006592, 233.4585876465, 233.2154388428, 232.9324 |
| | | 340820, 233.9463958740, 233.5576934814, 234.0729675293, 230.6853027344, 230.0452270508, 230. |
| | | 8823394775, 231.5001983643, 233.1339416504, 236.1669616699, 237.4540405273, 235.5567169189, |
| | | 232.4056549072, 230.8647460938, 230.8324737549, 232.5997467041, 231.9330444336, 230.15664672 |
| | | 85, 228.8305053711, 229.0610198975, 231.1870880127, 229.2646942139, 228.6304473877, 231.8301 |
| | | 849365, 233.5536956787, 235.2325744629, 233.7847900391, 234.1452026367, 231.5191955566, 230. |
| | | 4416198730, 229.6045989990, 229.4876251221, 232.4615020752, 231.3075103760, 230.9846191406, |
| | | 231.4215087891, 231.8365478516, 233.3049316406, 228.0194549561, 227.9775390625, 229.15786743 |
| | | 16, 231.2422637939, 234.8096771240, 233.2157135010, 232.8892669678, 231.9313659668, 230.3039 |
| | | 093018, 227.1973571777, 225.1174621582, 225.0984954834, 228.6483459473, 227.9111328125, 228. |
| | | 0480957031, 229.0083007812, 227.6951599121, 224.8233032227, 222.9555053711, 222.7927703857, |
| | | 224.9078369141, 223.9590301514, 224.4060363770, 222.9203033447, 222.2800140381, 222.28894042 |
| | | 97, 222.8032226562, 224.5366821289, 227.0157318115, 225.2642974854, 223.9855804443, 223.3911 |
| | | 590576, 223.7513427734, 227.8632049561, 225.4887390137, 225.5439453125, 225.5735473633, 225. |
| | | 8213043213, 227.1522369385, 230.6763916016, 228.8915863037, 224.3841705322, 223.4998626709, |
| | | 223.6578674316, 223.5919189453, 225.6020965576, 224.5933990479, 224.0125885010, 224.03222656 |
| | | 25, 227.7416534424, 227.6420745850, 227.9964141846, 229.0100097656, 227.4730377197, 226.2771 |
| | | 301270, 225.0067596436, 224.8537139893, 226.8142852783, 230.9336395264, 228.8516387939, 225. |
| | | 7774658203, 225.7509918213, 225.6688385010, 224.4594573975, 221.9644775391, 219.0105285645, |
| | | 220.0410614014, 220.5668029785, 224.6783142090, 228.5768280029, 230.3793487549, 230.31082153 |
| | | 32, 229.2327270508, 226.7379913330, 225.8885650635, 221.7596130371, 219.9652862549, 220.1135 |
| | | 711670, 220.7137908936, 222.1126098633, 221.9056549072, 223.5888366699, 223.4840087891, 222. |
| | | 4602203369, 222.1738281250, 221.3223571777, 221.3826446533, 223.4934844971, 225.2919158936, |
| | | 229.3796386719, 229.4648437500, 231.3547973633, 231.8081817627, 228.7029113770, 227.90339660 |
| | | 64, 225.4090881348, 222.7864532471, 222.0270538330, 222.8193511963, 222.7233581543, 222.4665 |
| | | 832520, 222.8473663330, 222.7880401611, 229.1417846680, 230.7284393311, 229.8651123047, 231. |
| | | 8110656738, 230.9190521240, 228.6879882812, 228.3954010010, 227.4387664795, 225.6394805908, |
| | | 224.8510131836, 223.3198699951, 222.6549682617, 223.9202270508, 227.0219268799, 227.17955017 |
| | | 09, 223.3169250488, 222.1465911865, 222.6952056885, 223.2734069824, 222.7868194580, 223.1713 |
| | | 256836, 222.5626220703, 223.5029296875, 226.0424804688, 225.6539916992, 225.4401550293, 225. |
| | | 7878875732, 224.9285278320, 226.3744354248, 226.9582214355, 228.9726867676, 227.4074249268, |
| | | 225.8544158936, 224.8072509766, 224.4407653809, 228.3143157959, 231.2576293945, 229.98553466 |
| | | 80, 228.9569091797, 229.4433593750, 228.4973907471, 226.5615844727, 226.8504791260, 225.3724 |
| | | 212646, 227.1776123047, 231.0649566650, 234.1764831543, 235.3388671875, 236.2540893555, 235. |
| | | 5808105469, 234.3077392578, 233.0715179443, 233.1971893311, 232.2679443359, 231.4796905518, |
| | | 231.6875000000, 231.5871276855, 230.0448760986, 230.4246673584, 231.3666839600, 232.72386169 |
| | | 43, 234.0981903076, 236.1051177979, 238.3867340088, 239.1369628906, 236.6306304932, 235.4361 |
| | | 724854, 236.6408538818, 236.4686889648, 235.3432006836, 237.9035186768, 238.8912200928, 240. |
| | | 5424957275, 241.1087951660, 241.9460906982, 240.5621490479, 240.1622467041, 240.8509063721, |
| | | 241.8372955322, 242.0060577393, 240.7857513428, 239.4638519287, 240.4606933594, 240.85128784 |
| | | 18, 241.9038391113, 243.2312164307, 244.2839202881, 244.2019500732, 247.0397796631, 246.7798 |
| | | 156738, 249.2990722656, 251.0794219971, 249.5334625244, 250.4516448975, 250.7070159912, 249. |
| | | 2634887695, 248.3024291992, 248.2539062500, 248.5850219727, 248.8466186523, 249.2846527100, |
| | | 249.6089630127, 249.8201599121, 250.0289154053, 248.6210937500, 248.6542510986, 249.24049377 |
| | | 44, 249.5879364014, 249.5558624268, 249.7000122070, 249.5428466797, 250.0638732910, 249.2076 |
| | | 110840, 249.6870117188, 249.5413513184, 249.6037902832, 249.7653045654, 249.7812652588, 251. |
| | | 7822265625, 252.8013305664, 251.6586761475, 251.8485107422, 253.1266326904, 253.7096099854, |
| | | 254.1781311035, 253.7182006836, 252.1824798584, 253.0978240967, 254.2611999512, 253.90533447 |
| | | 27, 252.5941009521, 253.3954162598, 252.3411102295, 253.0034332275, 253.9612579346, 254.2062 |
| | | 072754, 253.8478393555, 253.6345520020, 253.9709014893, 253.5397491455, 255.5663299561, 255. |
| | | 1592864990, 254.9006805420, 252.7778778076, 253.9928131104, 254.3068695068, 253.3880920410, |
| | | 253.5391235352, 253.6620941162, 253.6244812012, 251.7470855713, 251.5215606689, 253.20878601 |
| | | 07, 251.5159912109, 251.7874908447, 252.3263854980, 251.3667144775, 250.2662658691, 249.5995 |
| | | 483398, 249.7950134277, 247.8711547852, 246.5526275635, 245.9649810791, 245.4709472656, 244. |
| | | 1533660889, 242.6360931396, 241.8144683838, 240.7908325195, 242.6602325439, 242.7871398926, |
| | | 244.2416687012, 242.7000579834, 242.9482574463, 239.4070434570, 241.4149169922, 242.33071899 |
| | | 41, 240.7459716797, 239.4709014893, 238.9259185791, 240.9374389648, 242.2301483154, 241.8347 |
| | | 625732, 241.8262939453, 241.3443756104, 239.7543334961, 238.2615966797, 237.5140686035, 235. |
| | | 3566131592, 231.7252655029, 230.4790191650, 230.3171234131, 233.1614074707, 230.1933135986, |
| | | 229.6582336426, 231.0968627930, 233.7170715332, 233.5826110840, 235.9392700195, 238.20524597 |
| | | 17, 238.6011352539, 235.7082672119, 234.1982879639, 233.0641479492, 231.6160125732, 231.8119 |
| | | 354248, 232.7369232178, 231.4573211670, 231.8389282227, 235.6027526855, 244.0893707275, 244. |
| | | 1210479736, 243.5210266113, 245.9889373779, 242.7809448242, 240.9724426270, 238.7167205811, |
| | | 236.2595672607, 235.1962738037, 235.1151275635, 234.2746582031, 234.0340576172, 234.37925720 |
| | | 21, 235.4905395508, 234.6585083008, 234.3971710205, 232.4522094727, 234.7090759277, 233.5085 |
| | | 601807, 234.5184326172, 232.8786315918, 232.4489288330, 233.3515625000, 233.3668212891, 230. |
| | | 7961578369, 230.6512908936, 231.9561004639, 229.2053833008, 228.8329925537, 230.6472015381, |
| | | 230.6881713867, 229.3512573242, 226.4612579346, 226.2346038818, 226.5305786133, 226.25177001 |
| | | 95, 223.9136199951, 220.9597930908, 219.3715972900, 219.4178924561, 221.9481201172, 224.9949 |
| | | 798584, 227.4514007568, 226.1719207764, 225.5932922363, 225.2898254395, 226.9384918213, 227. |
| | | 3111724854, 227.5154724121, 231.6868896484, 230.2270355225, 229.6369781494, 229.6651611328, |
| | | 232.5938720703, 230.6569671631, 228.2633209229, 225.1286163330, 225.2893371582, 230.94459533 |
| | | 69, 235.5156402588, 233.3700103760, 231.6260986328, 229.0971374512, 227.1025238037, 227.1432 |
| | | 495117, 226.1050872803, 223.5411376953, 221.8954315186, 220.7680969238, 220.6626434326, 227. |
| | | 4432067871, 225.0029602051, 222.6836242676, 219.3010406494, 222.9712677002, 220.9671783447, |
| | | 223.1637420654, 226.3977508545, 224.9020538330, 223.6540985107, 224.2606506348, 229.50837707 |
| | | 52, 229.6203002930, 228.0922393799, 225.9828491211, 225.9857482910, 228.2182312012, 229.0090 |
| | | 179443, 225.2194671631, 229.1783752441, 229.9446258545, 228.7445373535, 228.7398834229, 224. |
| | | 0499267578, 223.3618621826, 224.0320587158, 224.0626525879, 226.0629882812, 227.5431823730, |
| | | 225.7254638672, 226.0943908691, 225.0453033447, 224.3965148926, 225.4459838867, 229.39358520 |
| | | 51, 230.9874877930, 230.4244995117, 230.9858703613, 226.0070648193, 225.4608459473, 225.5301 |
| | | 208496, 225.0221252441, 225.4174957275, 226.5843200684, 227.3665771484, 228.3926391602, 228. |
| | | 7713317871, 228.5853576660, 225.6349639893, 224.9035644531, 224.7528991699, 222.4460449219, |
| | | 220.1386413574, 219.2929534912, 216.7608032227, 219.0629272461, 224.3925476074, 230.98638916 |
| | | 02, 230.1822357178, 231.3697204590, 230.8611755371, 228.5159301758, 228.4338531494, 228.1074 |
| | | 676514, 228.2388153076, 227.8387451172, 228.6594390869, 226.4411163330, 221.9264221191, 221. |
| | | 2889099121, 222.1647796631, 224.1659851074, 223.4713897705, 222.6714935303, 224.8460388184, |
| | | 223.7722778320, 225.1019134521, 226.1131439209, 228.0272827148, 230.2188720703, 228.85656738 |
| | | 28, 228.1321105957, 226.6451721191, 226.9914398193, 230.8144989014, 233.5674133301, 234.4644 |
| | | 775391, 230.3761444092, 229.1539154053, 231.6634826660, 233.0186462402, 235.2396087646, 235. |
| | | 1782989502, 233.6075286865, 232.0706329346, 230.2009124756, 228.7839508057, 227.8674468994, |
| | | 226.4996032715, 224.3965454102, 224.3784637451, 225.6776885986, 229.1367034912, 231.23391723 |
| | | 63, 230.9084014893, 233.0245056152, 231.2011566162, 229.4620208740, 230.2925872803, 232.9522 |
| | | 399902, 230.4186248779, 229.1685638428, 227.6093139648, 227.6094360352, 226.5214233398, 225. |
| | | 0612792969, 226.8783721924, 229.1190032959, 230.4947967529, 232.5718078613, 234.8200378418, |
| | | 236.6606597900, 236.9986267090, 235.5780944824, 233.9425659180, 233.8031463623, 233.84405517 |
| | | 58, 233.9172363281, 233.4367370605, 233.2763061523, 233.4349975586, 234.1840972900, 234.6684 |
| | | 112549, 233.6848297119, 233.6032867432, 232.0831146240, 230.7225341797, 229.8591766357, 236. |
| | | 8748779297, 240.0663299561, 243.2444763184, 242.2235260010, 241.1168975830, 242.3988494873, |
| | | 242.2144775391, 241.3418426514, 241.4161071777, 241.6843872070, 241.5881652832, 241.31581115 |
| | | 72, 240.2924041748, 240.5908203125, 240.4049224854, 240.8152465820, 241.7900695801, 239.1941 |
| | | 223145, 238.7546997070, 239.5032043457, 239.1968536377, 240.9304962158, 244.0514831543, 242. |
| | | 8549346924, 242.1359405518, 242.6658630371, 243.0350341797, 244.3680419922, 246.1616058350, |
| | | 247.9228515625, 247.5212554932, 245.8093719482, 245.5377349854, 246.6408538818, 248.99539184 |
| | | 57, 249.4627685547, 249.4150543213, 249.8182983398, 249.4217834473, 250.2524414062, 251.5448 |
| | | 608398, 250.8833312988, 251.6781005859, 253.8616180420, 253.2546081543, 252.9741210938, 253. |
| | | 0247802734, 252.8273315430, 253.3489990234, 253.8708953857, 254.7782897949, 255.4923248291, |
| | | 255.9102172852, 255.7915802002, 254.5975646973, 253.3422393799, 253.0117950439, 253.84635925 |
| | | 29, 254.6704406738, 255.8343963623, 256.0698547363, 256.4809570312, 257.2196655273, 257.5474 |
| | | 853516, 257.9676513672, 258.7614135742, 259.4300231934, 260.5440673828, 260.3184814453, 260. |
| | | 2773132324, 260.4928894043, 260.4751892090, 260.5248413086, 259.8427734375, 259.4605407715, |
| | | 259.4945068359, 259.9406738281, 259.2377319336, 258.9628295898, 259.0859375000, 260.14703369 |
| | | 14, 260.7068481445, 259.3018798828, 258.8761596680, 258.5167846680, 258.8133544922, 257.4795 |
| | | 837402, 257.1966247559, 256.9448547363, 256.3989257812, 255.1857299805, 255.2497711182, 255. |
| | | 4969482422, 254.9381408691, 254.1422119141, 254.3852081299, 253.5728607178, 253.9102935791, |
| | | 254.5630950928, 254.4749450684, 254.2790679932, 255.0405578613, 255.3257446289, 254.24806213 |
| | | 38, 254.8069305420, 255.2963409424, 253.6978454590, 252.9501647949, 251.0729217529, 248.3867 |
| | | 950439, 247.3844909668, 245.8634033203, 244.2102966309, 246.5720672607, 246.9432678223, 247. |
| | | 8875579834, 246.5179138184, 243.8726196289, 244.5157165527, 243.5535430908, 240.4145355225, |
| | | 238.7828826904, 242.1218719482, 243.3038330078, 243.3298797607, 242.5348510742, 241.78541564 |
| | | 94, 242.0703887939, 242.2764739990, 243.4862670898, 242.8374938965, 241.7649993896, 242.0180 |
| | | 053711, 241.0657958984, 240.5607757568, 242.0352325439, 241.8761138916, 242.7515106201, 242. |
| | | 7733154297, 241.2646942139, 240.4768524170, 239.5198516846, 239.0121765137, 238.6118011475, |
| | | 237.3888854980, 237.7725677490, 242.0088958740, 245.8545227051, 241.2555847168, 239.95837402 |
| | | 34, 238.3329925537, 239.9030609131, 244.0008392334, 242.9119567871, 243.0151519775, 242.8132 |
| | | 934570, 240.5635375977, 239.0417327881, 235.7711029053, 234.9578094482, 234.8405151367, 234. |
| | | 8976135254, 234.8835754395, 234.2144470215, 233.8140869141, 233.7298583984, 233.5368957520, |
| | | 234.9080657959, 234.6400299072, 236.3074951172, 234.0128021240, 232.5044403076, 233.27990722 |
| | | 66, 233.8763732910, 237.3694915771, 237.0559997559, 237.3208618164, 235.1233062744, 235.0573 |
| | | 120117, 234.9002380371, 232.0088500977, 232.0363922119, 236.5143585205, 235.1988372803, 236. |
| | | 6164550781, 238.0803833008, 239.9303131104, 246.2989044189, 240.8476257324, 241.9757385254, |
| | | 240.8667297363, 240.9089965820, 245.1437530518, 243.8679962158, 238.9979095459, 237.49530029 |
| | | 30, 233.5875701904, 233.0692749023, 233.1133117676, 232.9631500244, 230.0248413086, 228.9835 |
| | | 052490, 229.0495605469, 231.7254486084, 235.9163818359, 234.5857543945, 233.7272033691, 230. |
| | | 3585205078, 228.5792236328, 228.1617736816, 228.1854095459, 230.2545318604, 229.9905853271, |
| | | 227.7571258545, 227.1296997070, 226.5204925537, 228.1013336182, 227.1313629150, 226.17752075 |
| | | 20, 223.4177703857, 224.2028045654, 228.4919128418, 227.2101898193, 227.5439453125, 225.7276 |
| | | 000977, 225.8390197754, 226.9507598877, 224.8664245605, 226.2128295898, 234.3193969727, 227. |
| | | 5362091064, 225.9082183838, 227.5162353516, 226.5371398926, 225.7717742920, 225.2196044922, |
| | | 225.1569519043, 225.4092559814, 228.2926635742, 232.7492370605, 235.8433837891, 235.67369079 |
| | | 59, 232.9666137695, 232.2114257812, 229.6145935059, 229.5724334717, 233.3196868896, 235.0071 |
| | | 258545, 236.2510681152, 236.6415252686, 234.0485992432, 233.9775390625, 231.0207366943, 229. |
| | | 8908843994, 229.1328582764, 230.8690643311, 230.5272521973, 231.5356140137, 231.9920349121, |
| | | 229.7577819824, 229.0018463135, 230.0742340088, 228.2611694336, 223.7417449951, 220.59326171 |
| | | 88, 220.9842681885, 224.7595672607, 224.5949707031, 225.5212097168, 228.1881561279, 231.0330 |
| | | 505371, 228.1475372314, 224.9059295654, 224.2282562256, 224.2932586670, 225.8555145264, 226. |
| | | 5674438477, 224.5435943604, 222.5779113770, 220.3059844971, 220.7720947266, 223.2222137451, |
| | | 224.5750427246, 224.1333770752, 225.3814697266, 226.6679992676, 226.4771728516, 225.07044982 |
| | | 91, 223.2102661133, 223.3845367432, 221.6613159180, 221.6627655029, 226.2789916992, 221.8675 |
| | | 384521, 221.4158020020, 223.5862579346, 222.4916229248, 221.5517120361, 220.9330291748, 220. |
| | | 8872985840, 223.1072387695, 225.6659545898, 223.5191650391, 221.6535644531, 220.7827606201, |
| | | 219.7181091309, 219.8031158447, 221.4284515381, 226.7514038086, 228.7241821289, 228.78630065 |
| | | 92, 225.9661407471, 224.1603698730, 223.9501800537, 226.1168975830, 224.0320587158, 223.5198 |
| | | 516846, 221.6248016357, 221.0466308594, 220.8952789307, 223.2277984619, 228.9370727539, 229. |
| | | 3185119629, 227.8545227051, 227.1171417236, 226.2785644531, 225.0637969971, 224.5190582275, |
| | | 224.0490875244, 223.3342285156, 223.0094451904, 223.1278991699, 223.8304443359, 226.43519592 |
| | | 29, 228.1504058838, 228.1401062012, 224.6646270752, 226.2149505615, 225.2922515869, 227.0949 |
| | | 096680, 230.1780090332, 231.1457366943, 233.7422637939, 230.5102081299, 230.8444366455, 229. |
| | | 0991821289, 229.0327301025, 231.3928375244, 233.1140594482, 234.4091644287, 231.9635772705, |
| | | 233.7606811523, 235.9697570801, 234.3105926514, 231.7361145020, 229.8963165283, 229.86836242 |
| | | 68, 230.7423706055, 229.8713073730, 232.0733337402, 236.2923583984, 236.2356872559, 236.0340 |
| | | 881348, 235.1665496826, 234.5847778320, 233.7778320312, 235.0847778320, 234.4659271240, 234. |
| | | 2897338867, 233.9093933105, 234.3715209961, 235.8922576904, 238.5845947266, 237.7242126465, |
| | | 234.2144927979, 239.2739562988, 242.9192199707, 243.4294433594, 244.5082855225, 243.02674865 |
| | | 72, 241.9486541748, 241.9343566895, 242.1728057861, 243.2154388428, 241.7377471924, 240.9216 |
| | | 766357, 241.0063323975, 241.4059753418, 241.8551330566, 242.0836029053, 241.8074951172, 241. |
| | | 6484375000, 242.9172210693, 243.5456542969, 244.4294738770, 245.1388092041, 245.1145477295, |
| | | 245.4396820068, 245.1575775146, 246.1074066162, 246.0692443848, 244.7617645264, 245.97865295 |
| | | 41, 248.2845001221, 249.2984619141, 250.5464630127, 250.3332672119, 250.2161560059, 249.8824 |
| | | 768066, 250.7696990967, 251.3146667480, 251.4622039795, 251.4181976318, 252.1407318115, 252. |
| | | 4109039307, 252.5157623291, 252.4664916992, 252.8130493164, 253.3655242920, 254.9162902832, |
| | | 255.7139587402, 256.1986083984, 254.6985473633, 255.1160736084, 255.4878387451, 255.60108947 |
| | | 75, 255.8978576660, 257.1939697266, 256.1646728516, 256.8655395508, 255.7386627197, 255.4086 |
| | | 303711, 255.3510589600, 255.0243835449, 256.6818847656, 256.3181152344, 255.7612304688, 255. |
| | | 4999847412, 255.7900390625, 256.0820617676, 255.9165344238, 256.4759521484, 255.2521820068, |
| | | 255.2446441650, 254.5858459473, 253.7789306641, 253.9988250732, 254.1046752930, 253.26660156 |
| | | 25, 253.4830932617, 253.5688629150, 253.0518951416, 252.3197631836, 251.6514434814, 253.0008 |
| | | 697510, 254.3700256348, 253.8192749023, 252.4496307373, 251.7536468506, 250.0452423096, 253. |
| | | 0150146484, 253.5683288574, 251.7364501953, 249.2091217041, 251.6913452148, 252.9809875488, |
| | | 251.4717864990, 251.0456695557, 251.6832122803, 251.9219818115, 250.4673156738, 249.13177490 |
| | | 23, 248.5168914795, 248.7161407471, 250.0343170166, 249.2553405762, 248.6072235107, 248.7533 |
| | | 874512, 249.4801483154, 248.1791839600, 246.8186492920, 245.0337066650, 244.5660552979, 243. |
| | | 9727172852, 244.0584716797, 243.7492828369, 244.0015563965, 244.8814697266, 244.7776184082, |
| | | 242.8744201660, 244.5423736572, 246.2676239014, 247.1073455811, 250.2183227539, 250.20529174 |
| | | 80, 247.7942962646, 245.5533599854, 244.8490600586, 244.8557128906, 243.8655700684, 243.6848 |
| | | 907471, 242.3450622559, 242.8427429199, 244.2517089844, 244.3213500977, 243.4803466797, 241. |
| | | 6962432861, 240.3529052734, 240.2197265625, 242.2395629883, 244.5486755371, 243.5710144043, |
| | | 241.5259399414, 239.0147857666, 239.0133972168, 239.5454559326, 240.5414581299, 240.07466125 |
| | | 49, 237.2659606934, 235.7580718994, 235.6319885254, 238.0121154785, 233.4216308594, 233.3661 |
| | | 804199, 234.3453979492, 232.4590301514, 230.9603881836, 230.5234680176, 228.7958984375, 228. |
| | | 2634582520, 229.4645843506, 231.2136993408, 231.8964691162, 231.6329956055, 231.3491668701, |
| | | 230.8518676758, 230.4252471924, 231.8802185059, 233.6856384277, 232.9059448242, 231.54750061 |
| | | 04, 232.2186431885, 233.1526489258, 232.8753967285, 232.6674804688, 234.0997467041, 233.6008 |
| | | 300781, 233.5805053711, 230.9942474365, 232.5650482178, 230.0959930420, 229.1584625244, 227. |
| | | 7648010254, 227.8154296875, 226.4648590088, 225.9588775635, 230.1753845215, 229.8560028076, |
| | | 230.0056457520, 236.8646392822, 234.0539550781, 230.8074798584, 230.7375335693, 233.20201110 |
| | | 84, 238.4620513916, 235.1446990967, 231.6582031250, 231.0861968994, 231.6520233154, 234.4816 |
| | | 741943, 234.5852508545, 238.0448913574, 235.2121887207, 235.2754058838, 236.0948028564, 232. |
| | | 3800659180, 230.7987670898, 230.6242828369, 228.5608367920, 228.5937652588, 229.2707824707, |
| | | 231.4581146240, 232.9916839600, 231.4049224854, 229.0834045410, 228.2257232666, 229.64459228 |
| | | 52, 230.4925079346, 228.7764739990, 228.2240753174, 228.6520080566, 231.0120849609, 232.1303 |
| | | 863525, 232.1896972656, 229.6482696533, 228.9786376953, 229.7156219482, 231.2268676758, 232. |
| | | 0108184814, 230.3741607666, 230.4594726562, 230.2778320312, 232.3797149658, 228.8965148926, |
| | | 227.3414459229, 227.3172912598, 229.7126159668, 230.5478363037, 228.9459075928, 228.76394653 |
| | | 32, 230.8027648926, 233.1821899414, 232.1042785645, 229.3157043457, 227.6390838623, 226.7095 |
| | | 947266, 226.9309997559, 226.4589843750, 226.4814605713, 226.9465789795, 229.0654296875, 228. |
| | | 4765014648, 229.3789367676, 232.5105285645, 233.9696350098, 232.5784149170, 232.3332366943, |
| | | 232.3667602539, 231.2748260498, 229.7063751221, 227.0174102783, 225.5456085205, 225.11140441 |
| | | 89, 227.0354614258, 230.0978546143, 226.6881103516, 226.6897735596, 226.6086883545, 226.8554 |
| | | 077148, 229.1616363525, 229.9076690674, 224.0240936279, 222.9477233887, 222.6492614746, 219. |
| | | 2231903076, 217.8921813965, 220.2790679932, 223.9654693604, 233.3141326904, 234.0035400391, |
| | | 225.8253631592, 223.7044677734, 225.7578125000, 231.0682525635, 231.2441253662, 227.44473266 |
| | | 60, 226.9121856689, 227.9655609131, 229.6280670166, 232.2373809814, 229.5231781006, 229.6827 |
| | | 545166, 227.2577819824, 225.1599578857, 229.2576904297, 229.2784729004, 227.9932708740, 225. |
| | | 3534698486, 223.3310394287, 223.0472869873, 222.4657745361, 222.0184020996, 222.0104522705, |
| | | 225.0698394775, 227.6780242920, 228.8438873291, 231.1831359863, 228.7397308350, 226.21759033 |
| | | 20, 225.4708709717, 226.1018524170, 226.8350830078, 228.3022155762, 225.4042663574, 223.5804 |
| | | 595947, 221.2420959473, 221.8160552979, 223.5680694580, 225.0988464355, 226.7311248779, 225. |
| | | 8022155762, 225.8297424316, 226.6643981934, 227.8300781250, 227.0026092529, 225.2141723633, |
| | | 229.9840698242, 232.4484558105, 231.4156951904, 227.9640502930, 225.9884948730, 225.07414245 |
| | | 61, 225.1916046143, 225.3458557129, 225.0137939453, 222.7581787109, 223.3556671143, 224.7026 |
| | | 824951, 227.8429870605, 230.6302032471, 233.0032806396, 231.3838500977, 229.8822326660, 231. |
| | | 0327453613, 232.1004486084, 230.8513183594, 228.1946563721, 226.8184814453, 228.0631866455, |
| | | 229.8001251221, 227.9952239990, 228.5702514648, 229.8237762451, 231.6109466553, 235.33663940 |
| | | 43, 240.5791015625, 235.2136840820, 234.3420715332, 235.4642486572, 237.6688842773, 238.1023 |
| | | 101807, 236.4130401611, 235.5390777588, 236.5104675293, 234.8709869385, 234.6700286865, 234. |
| | | 1266326904, 236.5508880615, 240.5224456787, 239.6761474609, 239.8207397461, 242.3845062256, |
| | | 242.7562408447, 243.5573883057, 246.2875213623, 246.3791198730, 244.2936096191, 243.61058044 |
| | | 43, 242.1309661865, 240.7055358887, 239.9871978760, 238.1313629150, 239.8016204834, 241.2280 |
| | | 731201, 243.8773956299, 245.8347930908, 244.1470947266, 243.3796081543, 243.5428924561, 242. |
| | | 6298675537, 243.1181488037, 243.4703826904, 244.0845794678, 243.7148437500, 243.2955780029, |
| | | 244.0852508545, 244.6930847168, 245.5613098145, 247.9527282715, 246.8468627930, 247.57730102 |
| | | 54, 246.7997741699, 248.7893218994, 250.5631103516, 251.4900970459, 252.2018127441, 251.6069 |
| | | 793701, 251.0298461914, 250.3893280029, 250.6585540771, 251.5334014893, 251.9029083252, 252. |
| | | 8395385742, 252.6712646484, 252.2398376465, 252.6922302246, 252.9033050537, 253.8055419922, |
| | | 254.3949890137, 256.1788024902, 254.3530120850, 255.9815673828, 257.7228698730, 258.16342163 |
| | | 09, 257.4068603516, 256.9360961914, 256.9197998047, 256.3633422852, 258.3241577148, 259.3698 |
| | | 730469, 259.4182128906, 259.7104492188, 259.4309082031, 259.2493286133, 258.1884155273, 257. |
| | | 1832275391, 257.2828369141, 257.5918579102, 257.6970825195, 257.3484191895, 257.9054260254, |
| | | 256.8812866211, 256.0797729492, 257.0786132812, 257.2240600586, 255.1450042725, 254.56645202 |
| | | 64, 256.0847167969, 256.1877441406, 255.8444976807, 257.4248046875, 258.7262268066, 259.2721 |
| | | 252441, 259.0399780273, 258.6134643555, 257.2033691406, 256.0419311523, 256.1479492188, 257. |
| | | 3415527344, 257.0816345215, 256.0281982422, 255.4609680176, 254.3125152588, 253.4447479248, |
| | | 253.1426696777, 252.9225006104, 252.3331909180, 251.3346252441, 250.3827209473, 251.91743469 |
| | | 24, 251.4155273438, 250.3517761230, 249.2895050049, 248.0874328613, 248.0308685303, 247.7311 |
| | | 096191, 247.4661407471, 247.0079193115, 245.6128845215, 247.7882080078, 248.7834320068, 250. |
| | | 4224700928, 250.3645477295, 250.6649475098, 249.3914642334, 246.6940460205, 243.9191436768, |
| | | 244.0198211670, 244.4914703369, 242.5814819336, 241.5064544678, 240.7631988525, 241.90431213 |
| | | 38, 238.5858764648, 237.5871582031, 240.0552368164, 238.7219848633, 239.6238555908, 237.8490 |
| | | 295410, 236.8724822998, 237.2570343018, 240.3287506104, 237.4199218750, 234.2148132324, 239. |
| | | 9097595215, 240.2669525146, 243.4050292969, 243.4205474854, 244.6934051514, 240.8963470459, |
| | | 236.8496704102, 234.0612182617, 233.5337829590, 237.0667419434, 241.8562164307, 237.02122497 |
| | | 56, 237.0701141357, 240.3785705566, 239.3143157959, 239.4115447998, 236.6188354492, 235.3692 |
| | | 779541, 235.0928192139, 234.7786865234, 234.4831237793, 232.0951995850, 231.5708923340, 231. |
| | | 9870605469, 234.9190521240, 234.8353881836, 234.7794036865, 236.9630126953, 237.9032287598, |
| | | 233.2222595215, 232.9468841553, 233.9074401855, 233.2976531982, 233.2898254395, 235.98278808 |
| | | 59, 235.6562194824, 234.1264343262, 233.6006622314, 235.1349182129, 235.5165863037, 235.6746 |
| | | 215820, 234.6065521240, 233.1926727295, 232.6638946533, 233.2540740967, 241.3670196533, 231. |
| | | 9172210693, 228.3917846680, 229.1126403809, 227.4912567139, 227.4173431396, 227.1036071777, |
| | | 228.1166076660, 230.2408447266, 230.0205841064, 233.6152801514, 228.9186401367, 227.40165710 |
| | | 45, 231.1130065918, 232.6198425293, 232.4959106445, 233.4827575684, 230.9226684570, 228.7073 |
| | | 059082, 226.5028228760, 226.4894104004, 228.3386230469, 230.0830841064, 231.6446075439, 229. |
| | | 2648620605, 227.7749176025, 227.8189239502, 226.8798370361, 226.7440948486, 228.2340393066, |
| | | 229.2062988281, 231.1333618164, 232.0231628418, 231.8145751953, 230.9170532227, 230.48451232 |
| | | 91, 230.6829071045, 227.7353668213, 224.4084472656, 224.3970489502, 232.6389465332, 235.1931 |
| | | 457520, 232.8918762207, 232.8703765869, 234.8209228516, 234.6650238037, 234.0745849609, 232. |
| | | 6261901855, 231.5495605469, 229.2786102295, 228.8293609619, 228.5737915039, 228.6119995117, |
| | | 232.6027679443, 232.5478210449, 231.5192260742, 231.5658569336, 232.7993011475, 231.54753112 |
| | | 79, 231.1981506348, 230.5028381348, 232.9717559814, 233.3167877197, 232.0183868408, 232.2645 |
| | | 111084, 232.2919006348, 232.2746429443, 232.3894195557, 233.0488433838, 234.7946777344, 234. |
| | | 8117980957, 235.0997009277, 235.2017517090, 231.8121795654, 231.8287811279, 232.6015014648, |
| | | 232.0606689453, 233.5093994141, 237.2900543213, 237.2349700928, 239.1059570312, 244.11387634 |
| | | 28, 242.6381072998, 240.4287261963, 239.1639709473, 239.0504150391, 240.6483001709, 243.3974 |
| | | 914551, 242.0849151611, 236.2102661133, 236.7319488525, 234.5799407959, 234.0469970703, 233. |
| | | 1774444580, 231.8666381836, 230.8474273682, 230.9358825684, 233.4315490723, 233.9849853516, |
| | | 234.0696563721, 232.8973236084, 232.9053497314, 232.9897003174, 233.8369598389, 234.91621398 |
| | | 93, 232.0375671387, 230.5785064697, 229.3522949219, 229.3642425537, 229.6566009521, 226.2603 |
| | | 912354, 226.3152313232, 226.8831329346, 227.9377746582, 229.5221557617, 229.0605773926, 230. |
| | | 1571655273, 226.7978363037, 226.8213806152, 223.9231719971, 223.5450134277, 224.2056427002, |
| | | 223.6304473877, 222.7589263916, 220.8750915527, 224.4521331787, 225.8292999268, 225.94171142 |
| | | 58, 227.6896362305, 227.9023284912, 229.4869079590, 229.0979919434, 224.6396026611, 224.6424 |
| | | 865723, 225.0110626221, 223.1267089844, 223.1976623535, 226.9033660889, 227.5445556641, 225. |
| | | 8045806885, 226.7215576172, 226.6808776855, 231.8386077881, 234.8589172363, 237.9242706299, |
| | | 233.7454071045, 231.1320648193, 230.9719085693, 238.5046539307, 238.0371398926, 236.95237731 |
| | | 93, 236.7583312988, 235.9055023193, 238.8117980957, 236.3798217773, 234.5943298340, 233.8230 |
| | | 895996, 233.0592346191, 232.0177001953, 231.3647918701, 232.0666656494, 233.6492004395, 234. |
| | | 8541870117, 236.6238403320, 236.3761444092, 233.7551269531, 232.3399505615, 235.5856170654, |
| | | 239.2435302734, 237.7868499756, 238.2763519287, 238.1132659912, 237.8501586914, 239.04393005 |
| | | 37, 239.3970336914, 240.5095367432, 240.7428588867, 240.5328521729, 241.6882019043, 242.5176 |
| | | 086426, 242.3020019531, 240.4692687988, 239.8246459961, 240.2279357910, 241.9065246582, 241. |
| | | 9435729980, 243.9657592773, 244.5767364502, 246.0482788086, 244.3667755127, 243.1009826660, |
| | | 241.6098937988, 242.5332946777, 244.4248046875, 243.9541931152, 245.8079833984, 245.76748657 |
| | | 23, 248.0710296631, 248.6444854736, 248.1483459473, 248.5353851318, 248.9656829834, 249.4506 |
| | | 683350, 249.3081512451, 249.7599182129, 251.1660156250, 250.9610595703, 251.1718597412, 251. |
| | | 4407653809, 250.6588897705, 250.1154174805, 250.4888916016, 251.5989379883, 250.7991485596, |
| | | 250.4816589355, 249.5908203125, 251.2969818115, 251.7224731445, 250.2289581299, 251.45378112 |
| | | 79, 251.1873626709, 254.2416229248, 254.5334320068, 255.6247558594, 256.9995117188, 257.6582 |
| | | 641602, 258.7712097168, 258.5837402344, 258.0374755859, 256.9586181641, 257.5087585449, 257. |
+============+==========+==============================================================================================+
Summary
-------
Selected 1 row out of 1
Execution time: 0.18 seconds
4- Run the Ophidia primitive to perform the linear regression over the time series. The apply operator with the oph_gsl_fit_linear primitive can be used.
NOTE: the resulting cube will just provide two values, the intercept and the slope.
[14]:
trendCube = singleTS.apply(
query="oph_gsl_fit_linear_coeff('OPH_FLOAT','OPH_FLOAT',measure, dimension,'110000')",
check_type='no')
5- Let’s plot the data with respect to the time dimensions (indexes), as well as the linear regression line in a scatter plot. Note that:
trendCoeff = trendCube.export_array(show_time='no')
intercept = trendCoeff['measure'][0]['values'][0][0]
slope = trendCoeff['measure'][0]['values'][0][1]
[15]:
%matplotlib inline
data = singleTS.export_array(show_time='no')
trendCoeff = trendCube.export_array(show_time='no')
import matplotlib.pyplot as plt
import matplotlib.lines as mlines
import matplotlib.transforms as mtransforms
import numpy as np
y = data['measure'][0]['values'][0][:]
x = data['dimension'][2]['values'][:]
fig, ax = plt.subplots(figsize=(11, 3), dpi=100)
ax.scatter(x, y)
intercept = trendCoeff['measure'][0]['values'][0][0]
slope = trendCoeff['measure'][0]['values'][0][1]
line = intercept + slope * np.array(x)
ax.plot(x,line, color='red')
plt.ylabel(data['measure'][0]['name'] + " (degK)")
plt.xlabel("Days since 2096/01/01")
plt.title('Minimum temperature')
plt.show()
('C:\\Users\\user\\Anaconda3\\lib\\site-packages\\PyOphidia\\cube.py', 4964) Unable to get dimensions from response: unpack requires a buffer of 4 bytes
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-15-35b6db67ff64> in <module>
14 ax.scatter(x, y)
15
---> 16 intercept = trendCoeff['measure'][0]['values'][0][0]
17 slope = trendCoeff['measure'][0]['values'][0][1]
18
TypeError: 'NoneType' object is not subscriptable
Finally clear your workspace from the datacubes produced during the experiments.
[ ]:
cube.Cube.deletecontainer(container='tasmin_day_CMCC-CESM_rcp85_r1i1p1_20960101-21001231.nc',force='yes')