koze[ke] = koze_ref[ke] # salvo le serie temporali filtrate e non (_all) for ke in ['labels', 'dist_centroid', 'pcs', 'dates']: koze[ke] = koze_ref[ke][mask == 1] # ricostruisco il pattern degli stati selezionati patts = ctl.reconstruct_from_pcs(koze['pcs'], koze['model_eofs']) cluspatt_ok = [] for reg in range(4): okpo = koze['labels'] == reg cluspatt_ok.append(np.mean(patts[okpo, ...], axis=0)) koze['cluspattern_area'] = np.stack(cluspatt_ok) koze['freq_clus'] = ctl.calc_clus_freq(koze['labels'], 4) koze['centroids'] = ctl.calc_effective_centroids( koze['pcs'], koze['labels'], 4) cd.plot_regimes( koze['lat_area'], koze['lon_area'], koze['cluspattern_area'], cart + 'regpatt_{}_{}_{}_v90.pdf'.format(season, area, tip), clatlo=clatlo, cbar_range=cbar_range, draw_contour_lines=False, cmappa='RdBu_r', n_color_levels=21) print(koze['lon_area']) reg_events[(season, tip, area)] = koze
freqs[('hist', mem, 'tot50')] = ctl.calc_clus_freq(results_hist[mem]['labels'], numclus) for reg in range(numclus): alltimes = results_hist[mem]['resid_times'][reg] residtimes[('hist', mem, 'mean', reg)] = np.mean(alltimes) residtimes[('hist', mem, 'p90', reg)] = np.percentile(alltimes, 90) patterns[('hist', mem, 'tot50')] = results_hist[mem]['eff_centroids'] dat1 = pd.Timestamp('09-01-1995').to_pydatetime() dat2 = pd.Timestamp('04-01-2014').to_pydatetime() alllabs_20, dats = ctl.sel_time_range(results_hist[mem]['labels'], results_hist[mem]['dates'], (dat1, dat2)) pcs, dats = ctl.sel_time_range(results_hist[mem]['pcs'], results_hist[mem]['dates'], (dat1, dat2)) alltimes_20, _, _ = ctl.calc_regime_residtimes(alllabs_20, dats) effcen = ctl.calc_effective_centroids(pcs, alllabs_20, numclus) for reg in range(numclus): residtimes[('hist', mem, 'mean_last20', reg)] = np.mean(alltimes_20[reg]) residtimes[('hist', mem, 'p90_last20', reg)] = np.percentile(alltimes_20[reg], 90) patterns[('hist', mem, 'last20')] = effcen freqs[('hist', mem, 'last20')] = ctl.calc_clus_freq(alllabs_20, numclus) for ssp in allssps: for mem in okmods_ssp: if mem not in results_ssp[ssp].keys(): continue ## Attach all members labels dat1 = pd.Timestamp('09-01-2050').to_pydatetime() dat2 = pd.Timestamp('04-01-2100').to_pydatetime() labs, dats = ctl.sel_time_range(results_ssp[ssp][mem]['labels'], results_ssp[ssp][mem]['dates'], (dat1, dat2))