Esempio n. 1
0
'''some definitions'''
area_def = load_area('areas.cfg', 'pc_world')
rlon = np.arange(-180, 180, .1)
rlat = np.arange(90, -90, -.1)

input_iusv_start = int(input("Enter start cruise processing number 0-10: "))
input_iusv_end = int(input("Enter stop cruise processing number 0-10: "))
adir_usv = str(input("Enter directory for USV data: "))
adir_l1r = str(input("Enter directory for L1R data: "))

#intialize grid
for iusv in range(input_iusv_start, input_iusv_end):

    file_save = []  #initialize variable for each processing run

    ds_usv, name_usv = read_usv(adir_usv, iusv)
    fileout = adir_usv + name_usv + 'AMSR2MMDB_filesave2_testing.nc'

    #search usv data
    minday, maxday = ds_usv.time[0], ds_usv.time[-1]
    usv_day = minday
    print(minday.data, maxday.data)

    while usv_day <= maxday:
        #while looping through USV data, look at data +-1 day
        ds_day = ds_usv.sel(time=slice(usv_day -
                                       np.timedelta64(1, 'D'), usv_day +
                                       np.timedelta64(1, 'D')))
        ilen = ds_day.time.size
        if ilen < 1:  #don't run on days without any data
            continue
#
# - loop through the satellite data
# - calculate the in situ min/max lat/lon on the same day to define a small box of interest
# - use pyresample to map the data onto a predefined 0.1 deg resolution spatial grid
# - subset the gridded map to the area of interest
# - see if there is any valid data in that area
# - if there is any valid data, save the filename into a list
#
#
input_iusv_start = int(input("Enter start cruise processing number 0-10: "))
input_iusv_end = int(input("Enter stop cruise processing number 0-10: "))
adir_usv = str(input("Enter directory for USV data: "))

#intialize grid
for iusv in range(input_iusv_start,input_iusv_end):
    ds_usv, usv_name = read_usv(adir_usv,iusv)
    print('usv', usv_name)
    fileout = adir_usv + 'mmdb_collocation_test/' + usv_name + 'AMSR2MMDB_usv2_testing.nc'
    ds_usv = xr.open_dataset(fileout)
# now collocation with orbital data is finished.  re-open file and create the mean values for each matchup so there aren't repeates

    fileout_norepeat = fileout[:-3]+'_norepeats_testing.nc'
 #   ds_usv = ds_usv.where(ds_usv.tb<10000,np.nan)
    ds_usv = ds_usv.where(ds_usv.amsr2_scan>10000,np.nan)  #keep valid scan nmbers, replace rest with nan
    ilen,index = ds_usv['insitu.time'].size,0
    ds_tem = ds_usv.copy(deep=True)
    dsst,dair,dwav,dpres,dsstu,dvwnd,duwnd,dsal,dchl,dgwnd,dlat,dlon,dut = [],[],[],[],[],[],[],[],[],[],[],[],np.empty((),dtype='datetime64')
    index=0
    while index <= ilen-2:
        index += 1
#        if np.isnan(ds_usv.tb[index]):
# - loop through the satellite data
# - calculate the in situ min/max lat/lon on the same day to define a small box of interest
# - use pyresample to map the data onto a predefined 0.1 deg resolution spatial grid
# - subset the gridded map to the area of interest
# - see if there is any valid data in that area
# - if there is any valid data, save the filename into a list
#
#
input_iusv_start = int(input("Enter start cruise processing number 0-10: "))
input_iusv_end = int(input("Enter stop cruise processing number 0-10: "))
adir_usv = str(input("Enter directory for USV data: "))

#intialize grid
for iusv in range(input_iusv_start,input_iusv_end):
    num_usv = 0
    ds_usv, usv_name = read_usv(adir_usv,num_usv)
    fileout = adir_usv + usv_name + 'AMSR2MMDB_usv2.nc'
    ds_usv = xr.open_dataset(fileout)
# now collocation with orbital data is finished.  re-open file and create the mean values for each matchup so there aren't repeates

    fileout_norepeat = fileout[:-3]+'_norepeats.nc'
    ds_usv = ds_usv.where(ds_usv.tb<10000,np.nan)
    ilen,index = ds_usv.dims['time'],0
    ds_tem = ds_usv.copy(deep=True)
    dsst,dair,dwav,dpres,dsstu,dvwnd,duwnd,dsal,dchl,dgwnd,dlat,dlon, dut = [],[],[],[],[],[],[],[],[],[],[],[],np.empty((),dtype='datetime64')
    index=0
    while index <= ilen-2:
        index += 1
        if np.isnan(ds_usv.tb[index]):
            continue
        if np.isnan(ds_usv.amsr2_scan[index]):