def PaTh_varSorted(): data, sta, date, lon, lat, P, d, t, s, Tpot, theta, Tr, fluo, oxy_uM, oxy_mL, rho, isop, si, ti, NO3_1, NO3_2, PO3_1, PO3_2, SiO4_1, SiO4_2, nut = Data.AllData_variables( ) PaThData, PaTh_sta, PaTh_lon, PaTh_lat, PaTh_t, PaTh_s, PaTh_theta, PaTh_rho, PaTh_d = Data.PaTh_variables( ) listAllSta = [] listPaThSta = [] for i in range(0, len(lon - 1), 1): if sta[i] not in listAllSta: listAllSta.append(sta[i]) if data.Th.notnull()[i]: if sta[i] not in listPaThSta: listPaThSta.append(sta[i]) from collections import OrderedDict d_sort = OrderedDict() for stn in listPaThSta: d_sort[stn] = PaThData[PaThData.Station == stn].sort_values( by='d', ascending=[True]) PaThDataSorted = pd.concat(d_sort.values()) #d_sort[listPaThSta[0]] ## This line and the line below are equivalent #d_sort['K1'] #PaThDataSorted PaThSort_sta = PaThDataSorted.Station PaThSort_d = PaThDataSorted.d Pa = PaThDataSorted.Pa Th = PaThDataSorted.Th PaTh = PaThDataSorted.PaTh PaErr = PaThDataSorted.PaErr ThErr = PaThDataSorted.ThErr PaThErr = PaThDataSorted.PaThErr return listAllSta, listPaThSta, PaThDataSorted, PaThSort_sta, PaThSort_d, Pa, Th, PaTh, PaErr, ThErr, PaThErr
def PaTh_variables(): data, sta, date, lon, lat, P, d, t, s, theta, Tpot, Tr, fluo, oxy_uM, oxy_mL, rho, isop, si, ti, NO3_1, NO3_2, PO3_1, PO3_2, SiO4_1, SiO4_2, nut = Data.AllData_variables( ) PaData = data[data.Pa.notnull( )] # PaData: select only rows where Pa is not NaN -> n=92 ThLost = PaData[ PaData.Th.isnull()] # Among PaData, select only rows where Th is NaN # (refer to Th sample lost)-> n=2 PaThData = pd.concat([data[data.Th > 0], PaData[PaData.Th.isnull()] ]) # Concatenate the rows where Th is not NaN # and where Th is NaN but Pa is not NaN -> n=94 #print(len(PaData),len(PaThData),'\n') #print(PaThData[PaThData.Station == 'BB3']) # Displays the rows of the table corresponding to the Pa and Th data # of the station BB3 PaTh_sta = PaThData.Station PaTh_lon = PaThData.lon PaTh_lat = PaThData.lat PaTh_t = PaThData.temp PaTh_s = PaThData.sal PaTh_theta = PaThData.theta PaTh_rho = PaThData.rho PaTh_d = PaThData.d return PaThData, PaTh_sta, PaTh_lon, PaTh_lat, PaTh_t, PaTh_s, PaTh_theta, PaTh_rho, PaTh_d