Weekly trends plot for different years

  • resampling frequency is 'freq' Days
  • various rates of the chlor-a concentration
  • composition plots for all years
  • binned plots using 'week no.' during November to March for all years and individual years
  • "fixed scale" seems more illustrative than the "min-max scale"

In [1]:
import xarray as xr
import numpy as np
import pandas as pd
%matplotlib inline
from matplotlib import pyplot as plt
from dask.diagnostics import ProgressBar
import seaborn as sns
from matplotlib.colors import LogNorm

In [2]:
# resampling frequency in number of days
freq=15

In [3]:
# load preprocessed float data, and start the interpolation right here!!!!
var7 = "chlrateweekno"
var6 = "sst4"
var5 = "par"
var4 = "t865"
var3 = "kd490"
var2 = "cdm"
var1 = "chl"
vardist = "dist"

indir_prefix = "../../data_collector_globcolour/output.data.interpolate/2017GDPfloat/" + "df_Globcolor_"
indir = indir_prefix + var1 + vardist + var2 + var3 + var4 + var5 + var6 + var7 + "_" + str(freq) + "d.csv"

floatDF_tmp = pd.read_csv(indir,index_col=0)
print(floatDF_tmp)


### plot for id 125776, which will be fit by LDS
plt.figure(figsize=(8,6))
floatDF_tmp[floatDF_tmp.id == 135776].plot(x='time', y ='chl_rate', title=('id - %d' % 135776) )
plt.show();
plt.close("all")


            time        id        lat        lon       temp         ve  \
0     2002-07-04     10206  16.265717  66.663800        NaN   6.140233   
1     2002-07-04     10208  13.549633  70.195217        NaN  11.373300   
2     2002-07-04     11089  15.657150  65.248067  27.773283   9.376883   
3     2002-07-04     15703  13.611350  70.165200  28.590333  10.194983   
4     2002-07-04     27069  19.969700  70.048350  28.916267  25.855350   
5     2002-07-04     28842  18.350883  60.961600  27.226833   5.825783   
6     2002-07-04     34159  13.394633  60.516650        NaN  31.603317   
7     2002-07-04     34210   5.882953  56.749953  26.354721  -5.144814   
8     2002-07-04     34211   7.797533  69.070367  28.430017  19.858683   
9     2002-07-04     34212   6.519433  66.877317  28.568833  34.703000   
10    2002-07-04     34310   5.023286  70.029000  28.954857   8.074714   
11    2002-07-04     34311   9.730864  69.980455  28.593818  -2.896714   
12    2002-07-04     34312   9.638095  65.167048  28.129857   7.005500   
13    2002-07-04     34314   5.116600  54.903200  26.905500  -6.718778   
14    2002-07-04     34315   5.162294  59.998824  28.303294 -17.022625   
15    2002-07-04     34708  10.333167  61.099483  27.384050  22.553517   
16    2002-07-04     34709   6.396520  52.252040  26.204160   0.462760   
17    2002-07-04     34710  12.618183  49.966633  31.137717 -15.991800   
18    2002-07-04     34714  13.767567  65.507833  27.870250  34.244133   
19    2002-07-04     34716   7.695783  66.931733  28.781367  25.851967   
20    2002-07-04     34718  14.420783  73.395800  28.827417  16.290550   
21    2002-07-04     34719  16.656500  71.694917  28.910950  14.472783   
22    2002-07-04     34720  13.938883  69.771467  28.658633  11.449783   
23    2002-07-04     34721  16.653933  65.645233  27.876133   5.294917   
24    2002-07-04     34722  10.935983  70.908850  28.703450   7.445617   
25    2002-07-04     34723  16.587100  66.599800  28.407783   5.319900   
26    2002-07-04   2134712   8.795967  64.194267  28.258667  12.196000   
27    2002-07-19     10206  16.072700  67.886683        NaN  14.527167   
28    2002-07-19     10208  12.458050  70.996300        NaN   0.988950   
29    2002-07-19     11089  14.965100  66.350767  27.791150   6.747217   
...          ...       ...        ...        ...        ...        ...   
2529  2017-06-15    147144  14.572667  70.179567  29.493000  10.190933   
2530  2017-06-15  62321990  13.434167  60.508167  28.278083  16.173300   
2531  2017-06-15  63157510   7.810517  59.133933  28.565683  27.087900   
2532  2017-06-15  63158530   7.241083  57.466850  29.115433  -7.467850   
2533  2017-06-15  63254860   6.650636  57.272091  29.173409 -13.571667   
2534  2017-06-15  63255180   5.942217  62.901967  29.877033   6.626267   
2535  2017-06-15  63255860   8.232364  56.526273  28.334909   0.638300   
2536  2017-06-15  63258900  11.394667  66.441133  29.527950  19.424917   
2537  2017-06-15  63258950   9.665528  67.081306  29.651694   4.542086   
2538  2017-06-15  63259180  10.315883  70.122550  29.755983  11.165400   
2539  2017-06-15  63259190   8.182300  71.503133  29.743433   2.719310   
2540  2017-06-15  63259230  11.710174  69.002391  29.589565   6.724391   
2541  2017-06-15  63348720   7.832875  58.230143  28.273804  31.217091   
2542  2017-06-15  63348750   5.647766  66.040532  30.124574   2.377617   
2543  2017-06-15  64111550  16.753833  67.083500  29.548500   4.374650   
2544  2017-06-15  64113560  14.357517  62.191567  28.389650  13.057833   
2545  2017-06-15  64115560  16.855283  72.553533  29.724217  10.948783   
2546  2017-06-15  64117500   6.810550  71.186017  29.476617   2.463900   
2547  2017-06-30    147140  11.557667  61.136333  28.039000  83.892000   
2548  2017-06-30    147144  14.291000  70.923667  29.260333  17.542500   
2549  2017-06-30  62321990  12.863000  61.727800  27.980800  24.212500   
2550  2017-06-30  63157510   8.170833  60.425000  28.591667  25.888400   
2551  2017-06-30  63158530   7.562400  57.591200  28.432600   2.102750   
2552  2017-06-30  63255180   6.457000  63.455750  29.492250  26.794667   
2553  2017-06-30  63258900  10.611667  67.725333  29.285333  11.653500   
2554  2017-06-30  63259180   9.708250  71.031750  29.490500  17.048000   
2555  2017-06-30  64111550  15.278385  67.633154  28.739692  14.127583   
2556  2017-06-30  64113560  13.827154  62.739077  27.976923   0.487667   
2557  2017-06-30  64115560  16.871250  73.274250  28.602000  -0.189000   
2558  2017-06-30  64117500   6.149231  71.412077  29.282000   3.511583   

             vn        spd   var_lat   var_lon     ...            sst4  \
0      0.357733   7.394967  0.001451  0.005610     ...       26.746639   
1     -5.285617  15.006967  0.000063  0.000118     ...       27.448522   
2    -14.097033  18.695917  0.000067  0.000129     ...       26.210833   
3     -4.513033  13.965250  0.000055  0.000102     ...       27.479784   
4     -5.424417  27.865400  0.000057  0.000106     ...       26.260804   
5     -9.921900  16.832533  0.000149  0.000362     ...       25.311138   
6     16.559017  36.755683  0.000061  0.000116     ...       25.655235   
7    -18.675465  26.752744  0.000066  0.000129     ...       26.094126   
8    -14.960467  27.234933  0.000053  0.000098     ...       27.342235   
9      1.993683  42.610483  0.000055  0.000102     ...       26.731024   
10    -0.021000  10.808286  0.000056  0.000103     ...       25.269258   
11   -11.504476  13.484762  0.000061  0.000114     ...       27.931790   
12   -15.195200  17.403650  0.000075  0.000154     ...       26.977055   
13    -5.381333  16.793444  0.000047  0.000087     ...       25.858873   
14     5.554625  28.943938  0.000052  0.000094     ...       27.263790   
15     4.269317  24.302933  0.000058  0.000110     ...       26.454226   
16    46.740240  81.157560  0.000079  0.000162     ...       24.545951   
17    -6.248550  46.052550  0.000046  0.000087     ...       30.260205   
18     1.335217  35.355967  0.000059  0.000110     ...       26.322131   
19     2.107750  34.797783  0.000057  0.000106     ...       27.134512   
20   -39.532167  44.367833  0.000055  0.000102     ...       27.061788   
21   -20.354250  26.786467  0.000060  0.000112     ...       27.679489   
22   -12.078667  20.477317  0.000061  0.000114     ...       27.872634   
23   -11.221400  13.610417  0.000058  0.000109     ...       26.262339   
24   -16.828850  20.732050  0.000061  0.000115     ...       27.855246   
25    -1.815867  10.339867  0.000064  0.000124     ...       27.386708   
26   -20.248500  29.976417  0.000085  0.000176     ...       27.410492   
27    -8.716150  19.262550  0.001116  0.004011     ...       26.844852   
28   -23.323367  26.479183  0.000065  0.000124     ...       27.317952   
29     6.272917  13.490517  0.000059  0.000109     ...       26.782853   
...         ...        ...       ...       ...     ...             ...   
2529  -2.238083  14.281700  0.000347  0.000176     ...       28.593525   
2530  -6.508667  18.012117  0.002924  0.002439     ...       27.203621   
2531   6.130500  34.657567  0.000010  0.000008     ...       27.226775   
2532   6.872683  28.816750  0.000076  0.000041     ...       28.180950   
2533 -13.335286  21.792000  0.002290  0.001733     ...       28.409090   
2534   6.505583  14.081183  0.000066  0.000034     ...       28.546088   
2535   0.823200   1.099600  0.018849  0.019519     ...       27.444098   
2536  -5.209017  26.490717  0.000199  0.000106     ...       27.745006   
2537 -28.119771  31.811457  0.000415  0.000222     ...       28.798787   
2538  -7.142583  15.643117  0.000918  0.000631     ...       28.615360   
2539  -7.233862   8.656517  0.007749  0.007112     ...       28.656855   
2540 -17.843696  21.039565  0.005488  0.004817     ...       28.505471   
2541 -17.404636  39.430727  0.008580  0.008565     ...       27.714849   
2542 -11.912617  15.776319  0.000015  0.000010     ...       29.447667   
2543 -12.741350  17.871400  0.000004  0.000006     ...       28.120017   
2544  -6.607233  16.582283  0.000069  0.000034     ...       28.178008   
2545  -1.390750  16.621250  0.000003  0.000005     ...       28.889565   
2546  -6.642417  15.401850  0.000003  0.000005     ...       28.733398   
2547 -12.843000  85.019000  0.000032  0.000014     ...       26.832599   
2548 -15.481500  23.507500  0.000129  0.000055     ...       27.056683   
2549 -13.379500  27.666750  0.008339  0.007574     ...       26.362764   
2550   5.273200  27.029800  0.000015  0.000010     ...       27.336787   
2551 -33.419500  33.622250  0.000004  0.000006     ...       26.763814   
2552  -4.388000  27.262333  0.000476  0.000268     ...       28.621569   
2553  -5.334000  12.912000  0.000794  0.000473     ...       27.979997   
2554 -12.979667  21.434667  0.000538  0.000273     ...       27.188253   
2555 -23.375000  27.887500  0.000003  0.000005     ...       27.041168   
2556  -8.357417  10.514917  0.000107  0.000049     ...       26.604775   
2557  16.893333  17.142667  0.000003  0.000005     ...       28.195331   
2558 -21.195083  22.225833  0.000003  0.000005     ...       28.521081   

      chlor_a_log_e  chl_rate  chl_log_e_rate  chl_rate_week  \
0               NaN       NaN             NaN            NaN   
1               NaN       NaN             NaN            NaN   
2               NaN       NaN             NaN            NaN   
3               NaN       NaN             NaN            NaN   
4               NaN       NaN             NaN            NaN   
5               NaN       NaN             NaN            NaN   
6         -1.135552       NaN             NaN            NaN   
7         -1.112637       NaN             NaN            NaN   
8         -2.340983       NaN             NaN            NaN   
9         -2.357158       NaN             NaN            NaN   
10        -2.207624       NaN             NaN            NaN   
11        -2.159895       NaN             NaN            NaN   
12        -1.796382       NaN             NaN            NaN   
13        -1.082853       NaN             NaN            NaN   
14        -1.729757       NaN             NaN            NaN   
15        -0.885504       NaN             NaN            NaN   
16        -0.689336       NaN             NaN            NaN   
17        -1.493217       NaN             NaN            NaN   
18        -1.066644       NaN             NaN            NaN   
19        -2.202286       NaN             NaN            NaN   
20        -0.868363       NaN             NaN            NaN   
21              NaN       NaN             NaN            NaN   
22        -1.443337       NaN             NaN            NaN   
23              NaN       NaN             NaN            NaN   
24              NaN       NaN             NaN            NaN   
25              NaN       NaN             NaN            NaN   
26        -1.741025       NaN             NaN            NaN   
27        -1.985205       NaN             NaN            NaN   
28        -2.310238       NaN             NaN            NaN   
29        -1.124097       NaN             NaN            NaN   
...             ...       ...             ...            ...   
2529            NaN       NaN             NaN            NaN   
2530            NaN       NaN             NaN            NaN   
2531      -1.155390  0.007379        0.028868       0.051653   
2532      -1.931810  0.002689        0.021754       0.018825   
2533      -1.653762  0.003109        0.018623       0.021761   
2534      -2.542798 -0.000514       -0.006235      -0.003598   
2535      -1.344081  0.002562        0.010626       0.017931   
2536            NaN       NaN             NaN            NaN   
2537      -2.257976 -0.001730       -0.014779      -0.012110   
2538      -2.493151 -0.004883       -0.042306      -0.034182   
2539      -2.185055  0.000702        0.006552       0.004913   
2540      -3.181475       NaN             NaN            NaN   
2541      -1.500046 -0.012159       -0.039829      -0.085116   
2542      -2.374661  0.000116        0.001262       0.000814   
2543            NaN       NaN             NaN            NaN   
2544            NaN       NaN             NaN            NaN   
2545            NaN       NaN             NaN            NaN   
2546      -2.083467       NaN             NaN            NaN   
2547      -0.856163  0.004354        0.011128       0.030475   
2548            NaN       NaN             NaN            NaN   
2549            NaN       NaN             NaN            NaN   
2550      -2.042855 -0.012352       -0.059164      -0.086462   
2551      -1.903409  0.000278        0.001893       0.001948   
2552      -2.032869  0.003488        0.033995       0.024413   
2553            NaN       NaN             NaN            NaN   
2554            NaN       NaN             NaN            NaN   
2555            NaN       NaN             NaN            NaN   
2556            NaN       NaN             NaN            NaN   
2557            NaN       NaN             NaN            NaN   
2558      -2.001766  0.000707        0.005447       0.004946   

      chl_log_e_rate_week  chl_rate_stand  chl_log_e_rate_stand  week  \
0                     NaN             NaN                   NaN    27   
1                     NaN             NaN                   NaN    27   
2                     NaN             NaN                   NaN    27   
3                     NaN             NaN                   NaN    27   
4                     NaN             NaN                   NaN    27   
5                     NaN             NaN                   NaN    27   
6                     NaN             NaN                   NaN    27   
7                     NaN             NaN                   NaN    27   
8                     NaN             NaN                   NaN    27   
9                     NaN             NaN                   NaN    27   
10                    NaN             NaN                   NaN    27   
11                    NaN             NaN                   NaN    27   
12                    NaN             NaN                   NaN    27   
13                    NaN             NaN                   NaN    27   
14                    NaN             NaN                   NaN    27   
15                    NaN             NaN                   NaN    27   
16                    NaN             NaN                   NaN    27   
17                    NaN             NaN                   NaN    27   
18                    NaN             NaN                   NaN    27   
19                    NaN             NaN                   NaN    27   
20                    NaN             NaN                   NaN    27   
21                    NaN             NaN                   NaN    27   
22                    NaN             NaN                   NaN    27   
23                    NaN             NaN                   NaN    27   
24                    NaN             NaN                   NaN    27   
25                    NaN             NaN                   NaN    27   
26                    NaN             NaN                   NaN    27   
27                    NaN             NaN                   NaN    29   
28                    NaN             NaN                   NaN    29   
29                    NaN             NaN                   NaN    29   
...                   ...             ...                   ...   ...   
2529                  NaN             NaN                   NaN    24   
2530                  NaN             NaN                   NaN    24   
2531             0.202075        0.162748              0.968680    24   
2532             0.152280        0.088122              0.764629    24   
2533             0.130360        0.094796              0.674803    24   
2534            -0.043647        0.037147             -0.038255    24   
2535             0.074383        0.086088              0.445414    24   
2536                  NaN             NaN                   NaN    24   
2537            -0.103452        0.017797             -0.283329    24   
2538            -0.296143       -0.032380             -1.072952    24   
2539             0.045866        0.056496              0.328556    24   
2540                  NaN             NaN                   NaN    24   
2541            -0.278806       -0.148168             -1.001910    24   
2542             0.008832        0.047177              0.176796    24   
2543                  NaN             NaN                   NaN    24   
2544                  NaN             NaN                   NaN    24   
2545                  NaN             NaN                   NaN    24   
2546                  NaN             NaN                   NaN    24   
2547             0.077895        0.114605              0.459808    26   
2548                  NaN             NaN                   NaN    26   
2549                  NaN             NaN                   NaN    26   
2550            -0.414150       -0.151228             -1.556533    26   
2551             0.013254        0.049755              0.194917    26   
2552             0.237967        0.100824              1.115762    26   
2553                  NaN             NaN                   NaN    26   
2554                  NaN             NaN                   NaN    26   
2555                  NaN             NaN                   NaN    26   
2556                  NaN             NaN                   NaN    26   
2557                  NaN             NaN                   NaN    26   
2558             0.038127        0.056571              0.296844    26   

      week_rotate  
0              37  
1              37  
2              37  
3              37  
4              37  
5              37  
6              37  
7              37  
8              37  
9              37  
10             37  
11             37  
12             37  
13             37  
14             37  
15             37  
16             37  
17             37  
18             37  
19             37  
20             37  
21             37  
22             37  
23             37  
24             37  
25             37  
26             37  
27             39  
28             39  
29             39  
...           ...  
2529           34  
2530           34  
2531           34  
2532           34  
2533           34  
2534           34  
2535           34  
2536           34  
2537           34  
2538           34  
2539           34  
2540           34  
2541           34  
2542           34  
2543           34  
2544           34  
2545           34  
2546           34  
2547           36  
2548           36  
2549           36  
2550           36  
2551           36  
2552           36  
2553           36  
2554           36  
2555           36  
2556           36  
2557           36  
2558           36  

[2559 rows x 27 columns]
<matplotlib.figure.Figure at 0x11d2f9eb8>

In [ ]:


In [ ]:


In [4]:
# https://stackoverflow.com/questions/16780014/import-file-from-parent-directory
# https://stackoverflow.com/questions/16771894/python-nameerror-global-name-file-is-not-defined
import os, sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath("__file__")))))

from tools import chl_rates  # del(chl_rates)
import importlib
importlib.reload(chl_rates)


Out[4]:
<module 'tools.chl_rates' from '/Users/vyan2000/work_linux/2Archive/myproject/20161024xray_oceancolor/ocean_color-master/tools/chl_rates.py'>

In [5]:
print("\n ******* Reduce the Dataset to 'Nov-01 to Mar-31' ******* \n" )
floatsDF_NovMar = chl_rates.reduce_to_NovMar(floatDF_tmp)

print("\n ******* weekly plots and spatial plots on various rates of chl-a and log-scale chl-a ******* \n")
chl_rates.spatial_plots_chl_rate_weekly(floatsDF_NovMar )


 ******* Reduce the Dataset to 'Nov-01 to Mar-31' ******* 

all the data count in [11-01, 03-31]  is  (752,)

 ******* weekly plots and spatial plots on various rates of chl-a and log-scale chl-a ******* 


 ****** summary of chl_log_e_rate ****** 
 count    752.000000
mean      -0.000716
std        0.035614
min       -0.219882
25%       -0.014602
50%        0.000992
75%        0.015575
max        0.140569
Name: chl_log_e_rate, dtype: float64
 ****** histogram of chl_log_e_rate ****** 
 count    752.000000
mean      -0.000716
std        0.035614
min       -0.219882
25%       -0.014602
50%        0.000992
75%        0.015575
max        0.140569
Name: chl_log_e_rate, dtype: float64
 ****** histogram of standardized chl_log_e_rate ****** 
 count    7.520000e+02
mean    -5.595406e-17
std      1.000000e+00
min     -6.153885e+00
25%     -3.898828e-01
50%      4.796866e-02
75%      4.574536e-01
max      3.967115e+00
Name: chl_log_e_rate, dtype: float64
 check check check 
            time     id        lat        lon       temp         ve         vn  \
136  2002-11-01  10206  11.003467  67.239550        NaN  -4.056967   4.393483   
137  2002-11-01  11089  14.262467  64.709467  28.889633 -13.725683  -0.383317   
138  2002-11-01  15707  13.536150  67.516567        NaN -15.863733 -13.316117   
139  2002-11-01  34315   6.525333  57.242750  29.443567 -15.565850   8.765583   
140  2002-11-01  34709  10.732667  74.960333  29.314833  -3.754333  18.614667   

           spd   var_lat   var_lon     ...            sst4  chlor_a_log_e  \
136   7.707300  0.000461  0.001396     ...       29.053078      -2.088498   
137  15.907100  0.000061  0.000116     ...       28.536541      -1.678196   
138  24.136500  0.000074  0.000146     ...       28.940634      -1.812138   
139  44.595400  0.000056  0.000106     ...       28.976899      -1.909677   
140  19.963167  0.000065  0.000122     ...       28.132019      -1.306209   

     chl_rate  chl_log_e_rate  chl_rate_week  chl_log_e_rate_week  \
136 -0.001116       -0.008450      -0.007811            -0.059147   
137  0.000743        0.004104       0.005202             0.028725   
138  0.000988        0.006343       0.006917             0.044404   
139 -0.005209       -0.028241      -0.036462            -0.197684   
140  0.007099        0.033302       0.049696             0.233114   

     chl_rate_stand  chl_log_e_rate_stand  week  week_rotate  
136        0.027569             -0.101775    44            1  
137        0.057152              0.258317    44            1  
138        0.061051              0.322564    44            1  
139       -0.037561             -0.669479    44            1  
140        0.158301              1.095876    44            1  

[5 rows x 27 columns]

 df_timed_NovMar.head() 
             time     id        lat        lon       temp         ve         vn  \
137  2002-11-01  11089  14.262467  64.709467  28.889633 -13.725683  -0.383317   
139  2002-11-01  34315   6.525333  57.242750  29.443567 -15.565850   8.765583   
140  2002-11-01  34709  10.732667  74.960333  29.314833  -3.754333  18.614667   
141  2002-11-01  34710  17.411183  63.079750  28.666317  -1.195583  16.525517   
142  2002-11-01  34721  12.702833  67.881250  29.393383   6.646367   6.486583   

           spd   var_lat   var_lon     ...            sst4  chlor_a_log_e  \
137  15.907100  0.000061  0.000116     ...       28.536541      -1.678196   
139  44.595400  0.000056  0.000106     ...       28.976899      -1.909677   
140  19.963167  0.000065  0.000122     ...       28.132019      -1.306209   
141  17.614183  0.000066  0.000127     ...       28.399822      -0.931270   
142  14.737233  0.000063  0.000121     ...       28.857789      -1.968210   

     chl_rate  chl_log_e_rate  chl_rate_week  chl_log_e_rate_week  \
137  0.000743        0.004104       0.005202             0.028725   
139 -0.005209       -0.028241      -0.036462            -0.197684   
140  0.007099        0.033302       0.049696             0.233114   
141 -0.008701       -0.019073      -0.060908            -0.133511   
142  0.001121        0.008551       0.007848             0.059858   

     chl_rate_stand  chl_log_e_rate_stand  week  week_rotate  
137        0.057152              0.258317    44            1  
139       -0.037561             -0.669479    44            1  
140        0.158301              1.095876    44            1  
141       -0.093136             -0.406508    44            1  
142        0.063169              0.385894    44            1  

[5 rows x 27 columns]

 ****** weekly plot of chl_log_e_rate_week ****** 

 ****** weekly plot of chl_rate_week ****** 

 ****** weekly plot of nondimensionalized daily chl_log_e_rate ****** 

 ****** weekly plot of nondimensionalized daily chl_rate ****** 

 ****** weekly plot of standardized nondimensionalized-daily chl_log_e_rate ****** 

 ****** weekly plot of standardized nondimensionalized-daily chl_rate ****** 

 ****** spatial plot of standardized nondimensionalized-daily chl_rate ****** 



 summary of the Chl_rate 
 count    126.000000
mean      -0.051777
std        0.608401
min       -6.783886
25%       -0.019682
50%        0.004111
75%        0.030064
max        0.266950
Name: chl_rate_week, dtype: float64
/Users/vyan2000/work_linux/2Archive/myproject/20161024xray_oceancolor/ocean_color-master/tools/chl_rates.py:656: FutureWarning: to_datetime is deprecated. Use pd.to_datetime(...)
  aa = df_timed_NovMar_ind[df_timed_NovMar_ind.index.to_datetime().month == month_ind[i]]

 summary of the Chl_rate 
 count    123.000000
mean       0.022655
std        0.198262
min       -1.089116
25%       -0.003115
50%        0.011859
75%        0.047177
max        1.079554
Name: chl_rate_week, dtype: float64

 summary of the Chl_rate 
 count    147.000000
mean       0.068912
std        0.274771
min       -0.238723
25%       -0.010911
50%        0.006525
75%        0.036153
max        2.324908
Name: chl_rate_week, dtype: float64

 summary of the Chl_rate 
 count    125.000000
mean       0.149677
std        0.670089
min       -2.999615
25%       -0.023685
50%       -0.001427
75%        0.048353
max        3.535475
Name: chl_rate_week, dtype: float64

 summary of the Chl_rate 
 count    189.000000
mean      -0.219524
std        0.966132
min       -6.387030
25%       -0.077694
50%       -0.013838
75%        0.005211
max        3.059905
Name: chl_rate_week, dtype: float64
Out[5]:
0

In [ ]:


In [ ]:


In [6]:
floatsDF_NovMar['time'] = pd.to_datetime(floatsDF_NovMar['time']) # ,format='%m/%d/%y %I:%M%p'
floatsDF_NovMar = floatsDF_NovMar.set_index('time')
# add a new column to the dataset
floatsDF_NovMar['year'] = floatsDF_NovMar.index.year
floatsDF_NovMar[:20]

year_max = floatsDF_NovMar.index.year.max()
year_min = floatsDF_NovMar.index.year.min()
print('year_max', year_max)
print('year_min', year_min)
#print(df_timed)


year_max 2017
year_min 2002

In [7]:
### Part 1: Plot for the mean of the weekly trends
### Mean
start = year_min
for i in range(0,3):
    #plt.subplot(311+i)
    plt.figure(figsize=(8,6))
    plt.title("mean of the weekly-binned standardized Lagrangian rate of change per day of Chl-a", fontsize=10)
    for current_year in range(start, start+5):
        mask = floatsDF_NovMar.year == current_year
        df_yearly = floatsDF_NovMar[mask]
        #print('\n summary statistics of chl_rate_week for the year %d \n' % (current_year) )
        #print(df_yearly.chl_rate_week.describe())
        axes1=df_yearly.groupby(['week_rotate'])['chl_rate_stand'].mean().plot(linestyle="-", linewidth=0.8,  label='%d' % current_year  )

    start = start + 5
    axes1.set_ylim(-1.5, 1)
    #axes1.set_title("Year " + str(current_year) + ": Line plot of the weekly data on the rate of change per week of the $Chl_a$ Concentration",  fontsize=10)
    plt.xlabel('week', fontsize=10)
    plt.ylabel('rate of change of the $Chl_a$ in $mg/(m^3 \cdot days)$', fontsize=10)
    plt.yticks(np.arange(-1.5, 1, 0.25))
    plt.xticks(np.arange(1, 25, 1))

    axes1.legend(bbox_to_anchor=(1.15, 1.05))
    #plt.savefig(str(freq)+"D_weekly_mean_" + str(i) +".pdf")
    plt.show()
    
    plt.close()



In [8]:
### Part 4: Plot for the 75% quantile of the weekly trends
### 85% quantile
start = year_min
for i in range(0,3):
    #plt.subplot(311+i)
    plt.figure(figsize=(8,6))
    plt.title("85% of the weekly-binned standardized Lagrangian rate of change per day of Chl-a", fontsize=10)
    for current_year in range(start, start+5):
        mask = floatsDF_NovMar.year == current_year
        df_yearly = floatsDF_NovMar[mask]
        #print('\n summary statistics of chl_rate_week for the year %d \n' % (current_year) )
        #print(df_yearly.chl_rate_week.describe())
        axes1=df_yearly.groupby(['week_rotate'])['chl_rate_stand'].quantile(.85).plot(linestyle="-", linewidth=0.8,  label='%d' % current_year  )

    start = start + 4
    axes1.set_ylim(-1, 1)
    #axes1.set_title("Year " + str(current_year) + ": Line plot of the weekly data on the rate of change per week of the $Chl_a$ Concentration",  fontsize=10)
    plt.xlabel('week', fontsize=10)
    plt.ylabel('rate of change of the $Chl_a$ in $mg/(m^3 \cdot days)$', fontsize=10)
    plt.yticks(np.arange(-1, 1, 0.25))
    plt.xticks(np.arange(1, 25, 1))

    axes1.legend(bbox_to_anchor=(1.15, 1.05))
    #plt.savefig(str(freq)+"D_weekly_quantile(75)_" + str(i) +".pdf")
    plt.show()  
    plt.close()



In [9]:
### Part 2: Plot for the median of the weekly trends
### Median
start = year_min
for i in range(0,3):
    #plt.subplot(311+i)
    plt.figure(figsize=(8,6))
    plt.title("median of the weekly-binned standardized Lagrangian rate of change per day of Chl-a", fontsize=10)
    for current_year in range(start, start+5):
        mask = floatsDF_NovMar.year == current_year
        df_yearly = floatsDF_NovMar[mask]
        #print('\n summary statistics of chl_rate_week for the year %d \n' % (current_year) )
        #print(df_yearly.chl_rate_week.describe())
        axes1=df_yearly.groupby(['week_rotate'])['chl_rate_stand'].quantile(.50).plot(linestyle="-", linewidth=0.8,  label='%d' % current_year  )

    start = start + 4
    axes1.set_ylim(-1, 1)
    #axes1.set_title("Year " + str(current_year) + ": Line plot of the weekly data on the rate of change per week of the $Chl_a$ Concentration",  fontsize=10)
    plt.xlabel('week', fontsize=10)
    plt.ylabel('rate of change of the $Chl_a$ in $mg/(m^3 \cdot days)$', fontsize=10)
    plt.yticks(np.arange(-1, 1, 0.25))
    plt.xticks(np.arange(1, 25, 1))

    axes1.legend(bbox_to_anchor=(1.15, 1.05))
    #plt.savefig(str(freq)+"D_weekly_median_" + str(i) +".pdf")
    plt.show()  
    plt.close()



In [10]:
### Part 3: Plot for the 25% quantile of the weekly trends
### 15% quantile
start = year_min
for i in range(0,3):
    #plt.subplot(311+i)
    plt.figure(figsize=(8,6))
    plt.title("15% quantile of the weekly-binned standardized Lagrangian rate of change per day of Chl-a", fontsize=10)
    for current_year in range(start, start+5):
        mask = floatsDF_NovMar.year == current_year
        df_yearly = floatsDF_NovMar[mask]
        #print('\n summary statistics of chl_rate_week for the year %d \n' % (current_year) )
        #print(df_yearly.chl_rate_week.describe())
        axes1=df_yearly.groupby(['week_rotate'])['chl_rate_stand'].quantile(.15).plot(linestyle="-", linewidth=0.8,  label='%d' % current_year  )

    start = start + 4
    axes1.set_ylim(-2, 1)
    #axes1.set_title("Year " + str(current_year) + ": Line plot of the weekly data on the rate of change per week of the $Chl_a$ Concentration",  fontsize=10)
    plt.xlabel('week', fontsize=10)
    plt.ylabel('rate of change of the $Chl_a$ in $mg/(m^3 \cdot days)$', fontsize=10)
    plt.yticks(np.arange(-2, 1, 0.25))
    plt.xticks(np.arange(1, 25, 1))

    axes1.legend(bbox_to_anchor=(1.15, 1.05))
    #plt.savefig(str(freq)+"D_weekly_quantile(25)_" + str(i) +".pdf")
    plt.show()  
    plt.close()



In [11]:
#matplotlib.pyplot.close("all")
plt.close('all')
plt.cla()  # axis
plt.clf()  # figure
plt.show()


<matplotlib.figure.Figure at 0x121188240>

In [ ]:


In [ ]:


In [12]:
year_max = floatsDF_NovMar.index.year.max()
year_min = floatsDF_NovMar.index.year.min()
print('year_max', year_max)
print('year_min', year_min)
#print(df_timed)


year_max 2017
year_min 2002

In [13]:
# [print(i) for i in range(year_min,year_max+1)]
# for  each year


for current_year in range(year_min, year_max+1):
    mask = floatsDF_NovMar.year == current_year
    df_yearly = floatsDF_NovMar[mask]

    print('\n summary statistics of chl_rate_stand for the year %d \n' % (current_year) )
    print(df_yearly.chl_rate_stand.describe())


    plt.figure(figsize=(8,6))
    axes1=df_yearly.groupby(['week_rotate'])['chl_rate_stand'].mean().plot(linestyle="-",color='b', linewidth=1)
    df_yearly.groupby(['week_rotate'])['chl_rate_stand'].quantile(.85).plot(linestyle="--",color='g', linewidth=0.35)
    df_yearly.groupby(['week_rotate'])['chl_rate_stand'].quantile(.50).plot(linestyle="--",color='r', linewidth=0.75)
    df_yearly.groupby(['week_rotate'])['chl_rate_stand'].quantile(.15).plot(linestyle="--",color='g', linewidth=0.35)
    axes1.set_ylim(-2, 2)
    axes1.set_title("Year " + str(current_year) + ": Line plot of the weekly data on the standardized rate of change per day of the $Chl_a$ Concentration",  fontsize=10)
    plt.xlabel('week', fontsize=10)
    plt.ylabel('rate of change of the $Chl_a$ in $mg/(m^3 \cdot day)$', fontsize=10)
    plt.yticks(np.arange(-2, 2, 0.25))
    plt.xticks(np.arange(1, 25, 1))
    plt.show()
    plt.close()


    # http://pandas.pydata.org/pandas-docs/version/0.19.1/visualization.html
    #http://blog.bharatbhole.com/creating-boxplots-with-matplotlib/
    plt.figure(figsize=(8,6))
    axes2 = df_yearly.boxplot(column='chl_rate_stand', by='week_rotate')
    axes2.set_ylim(-2, 2)
    #axes2.set_title("Box plot of the weekly data \n on the rate of change per week of the $Chl_a$ Concentration",  fontsize=10)
    plt.title("Year " + str(current_year) + ": Box plot of the weekly data \n on the standardized rate of change per day of the $Chl_a$ Concentration",  fontsize=10)
    plt.suptitle("") # remove auto-title
    plt.xlabel('week', fontsize=10)
    plt.ylabel('rate of change of the $Chl_a$ in $mg/(m^3 \cdot day)$', fontsize=10)
    plt.yticks(np.arange(-2, 2, 0.25))
    plt.xticks(np.arange(1, 25, 1))
    plt.show()
    plt.close()
    # the rate of change is slower on the regular scale

#matplotlib.pyplot.close("all")
plt.close('all')
plt.cla()  # axis
plt.clf()  # figure
plt.show()


 summary statistics of chl_rate_stand for the year 2002 

count    32.000000
mean      0.079667
std       0.618020
min      -2.430560
25%       0.035347
50%       0.060452
75%       0.153291
max       2.379484
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x11d87ea20>
 summary statistics of chl_rate_stand for the year 2003 

count    22.000000
mean      0.056391
std       1.128439
min      -4.092333
25%      -0.031316
50%       0.064080
75%       0.141765
max       2.728143
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x121c670f0>
 summary statistics of chl_rate_stand for the year 2004 

count    8.000000
mean     0.080786
std      0.058180
min      0.014035
25%      0.046554
50%      0.057858
75%      0.106318
max      0.178259
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x121906828>
 summary statistics of chl_rate_stand for the year 2005 

count    26.000000
mean      0.082832
std       0.085023
min      -0.101206
25%       0.009433
50%       0.087450
75%       0.146147
max       0.221679
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x121939c88>
 summary statistics of chl_rate_stand for the year 2006 

count    62.000000
mean      0.029420
std       0.093934
min      -0.157053
25%      -0.006300
50%       0.023777
75%       0.054595
max       0.259389
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x121c4e2b0>
 summary statistics of chl_rate_stand for the year 2007 

count    69.000000
mean      0.070906
std       0.095562
min      -0.131294
25%       0.024412
50%       0.053134
75%       0.102797
max       0.616884
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x120c96978>
 summary statistics of chl_rate_stand for the year 2008 

count    90.000000
mean     -0.339202
std       1.886347
min      -8.842898
25%      -0.012388
50%       0.033581
75%       0.063520
max       4.218526
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x122177fd0>
 summary statistics of chl_rate_stand for the year 2009 

count    30.000000
mean     -0.013963
std       0.234668
min      -0.848762
25%       0.012210
50%       0.041786
75%       0.076341
max       0.318353
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x120fbcf28>
 summary statistics of chl_rate_stand for the year 2010 

count    42.000000
mean      0.016661
std       0.062677
min      -0.198231
25%      -0.020632
50%       0.025816
75%       0.061545
max       0.128478
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x1221dddd8>
 summary statistics of chl_rate_stand for the year 2011 

count    19.000000
mean      0.110430
std       0.258444
min      -0.576656
25%       0.035263
50%       0.050508
75%       0.145503
max       0.782466
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x121b81748>
 summary statistics of chl_rate_stand for the year 2012 

count    27.000000
mean      0.020684
std       0.734537
min      -2.493636
25%      -0.121539
50%       0.049327
75%       0.158047
max       2.404216
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x1202d32e8>
 summary statistics of chl_rate_stand for the year 2013 

count    17.000000
mean     -0.782101
std       3.776319
min     -15.376479
25%      -0.030981
50%       0.066250
75%       0.098707
max       1.312095
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x120fdfe48>
 summary statistics of chl_rate_stand for the year 2014 

count    107.000000
mean       0.067761
std        1.296353
min       -7.110382
25%       -0.010461
50%        0.074645
75%        0.172051
max        5.987511
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x11b802128>
 summary statistics of chl_rate_stand for the year 2015 

count    53.000000
mean      0.131885
std       1.572503
min      -6.773697
25%      -0.010387
50%       0.053122
75%       0.169815
max       5.407521
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x11d79b710>
 summary statistics of chl_rate_stand for the year 2016 

count    63.000000
mean      0.067907
std       0.183180
min      -0.520853
25%       0.000070
50%       0.061900
75%       0.116359
max       0.731459
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x1211344e0>
 summary statistics of chl_rate_stand for the year 2017 

count    85.000000
mean      0.090908
std       2.778736
min     -14.474308
25%      -0.001291
50%       0.057848
75%       0.175568
max       8.082522
Name: chl_rate_stand, dtype: float64
<matplotlib.figure.Figure at 0x120e57518>
<matplotlib.figure.Figure at 0x12179a160>

In [ ]:


In [ ]: