<jupyter_start><jupyter_text>read in collocated files<jupyter_code>data_dir = 'F:/data/cruise_data/saildrone/sss/sss_collocations/'
#data_dir = 'F:/data/cruise_data/saildrone/sss_collocations_norepeat/'
filenames = [x for x in glob(data_dir+'*.nc')]
filenames
for file in filenames:
    ds = xr.open_dataset(file)
    ds.close()
    print(np.sum(ds.smap_name.str.contains('RSS')).data,np.sum(ds.smap_name.str.contains('JPL')).data)
print(ds.smap_name[2963].data,ds.smap_rev_number[2963].data)
#np.sum(ds.smap_name.where('JPL' in ds.smap_name))
np.sum(ds.smap_name.str.contains('RSS'))
data_dict={}
for iname,name in enumerate(filenames):
    ds = xr.open_dataset(name)
    ds.close()
    i = name.find('\\')
    sname = name[i+1:-3]
    if iname==0:
        data_dict = {name:ds}
    else:
        data_dict[name]=ds
 
fig, axs = plt.subplots(4,4,figsize=(12,12))
ii=0
for iname,name in enumerate(data_dict):
    ii1=int(ii/4)
    ii2=ii-ii1*4
    print(ii,ii1,ii2)
    ds = data_dict[name]
    dif = ds.SAL_CTD_MEAN - ds.smap_SSS
    dif = dif.where((ds.smap_SSS>2) & (ds.smap_SSS<50) & (ds.SAL_CTD_MEAN<50))
    difm = np.nanmean(dif)
    difs = np.nanstd(dif)
    print(iname,"{:.2f}".format(difm),"{:.2f}".format(difs),np.isfinite(dif).sum().data)
    if np.isfinite(difm):
        ax = axs[ii1,ii2]
        ax.plot(ds.SAL_CTD_MEAN)
        ax.plot(ds.smap_SSS)
        ii+=1

plt.plot(ds.SAL_CTD_MEAN)
plt.plot(ds.smap_SSS)
ds = sv.copy(deep=True)
dif = ds.SAL_CTD_MEAN - ds.smap_SSS
dif = dif.where((ds.smap_SSS>2) & (ds.smap_SSS<50) & (ds.SAL_CTD_MEAN<50))
difm = np.nanmean(dif)
difs = np.nanstd(dif)
difm
ds=sv
dif = ds.SAL_CTD_MEAN - ds.smap_SSS
dif = dif.where(ds.smap_SSS>50)

dif<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup