def save_SWOT(cycle, sgrid, err, p, time=[], vindice=[], SSH_true=[]): file_output = p.file_output + '_c' + str(cycle + 1).zfill(2) + '_p' + str( sgrid.ipass).zfill(3) + '.nc' OutputSWOT = rw_data.Sat_SWOT(file=file_output, lon=(sgrid.lon + 360) % 360, lat=sgrid.lat, time=time, x_ac=sgrid.x_ac, x_al=sgrid.x_al, cycle=sgrid.cycle, lon_nadir=(sgrid.lon_nadir + 360) % 360, lat_nadir=sgrid.lat_nadir) OutputSWOT.gridfile = sgrid.gridfile OutputSWOT.write_data(SSH_model=SSH_true, index=vindice, roll_err=err.roll, bd_err=err.baseline_dilation, phase_err=err.phase, ssb_err=err.ssb, karin_err=err.karin, pd_err_1b=err.wet_tropo1, pd_err_2b=err.wet_tropo2, pd=err.wt, timing_err=err.timing, SSH_obs=err.SSH) return None
def save_SWOT(cycle, sgrid, err, p, out_var, time=[], save_var='all'): ofile = '{}_c{:02d}_p{:03d}.nc'.format(p.file_output, cycle + 1, sgrid.ipass) OutputSWOT = rw_data.Sat_SWOT(nfile=ofile, lon=(sgrid.lon + 360) % 360, lat=sgrid.lat, time=time, x_ac=sgrid.x_ac, x_al=sgrid.x_al, cycle=sgrid.cycle, lon_nadir=(sgrid.lon_nadir + 360) % 360, lat_nadir=sgrid.lat_nadir) OutputSWOT.gridfile = sgrid.gridfile OutputSWOT.first_time = p.first_time err.SSH2 = err.SSH if save_var == 'mockup': all_var = make_empty_vars(sgrid) beam_pos = (12, 47) tmp_var = +err.SSH flag = make_flags(tmp_var, sgrid, p.modelbox, beam_pos) all_var['karin_surf_type'] = out_var['mask_land'] all_var['rad_surf_type'][:, 0] = out_var['mask_land'][:, beam_pos[0]] all_var['rad_surf_type'][:, 1] = out_var['mask_land'][:, beam_pos[1]] all_var['ssh_karin_swath'] = +err.SSH all_var['ssha_uncert'] = err.karin else: all_var = None err.SSH2 = None flag = None if save_var == 'expert': OutputSWOT.write_data(out_var, roll_err_1d=err.roll1d, phase_err_1d=err.phase1d, bd_err_1d=err.baseline_dilation1d, ssb_err=err.ssb, karin_err=err.karin, pd_err_1b=err.wet_tropo1, pd_err_2b=err.wet_tropo2, pd=err.wt, timing_err_1d=err.timing1d) elif save_var == 'mockup': OutputSWOT.write_data(empty_var=all_var) else: OutputSWOT.write_data( out_var, roll_err=err.roll, bd_err=err.baseline_dilation, phase_err=err.phase, ssb_err=err.ssb, karin_err=err.karin, pd_err_1b=err.wet_tropo1, pd_err_2b=err.wet_tropo2, pd=err.wt, timing_err=err.timing, ssh_obs=err.SSH, ) return None
def load_sgrid(sgridfile, p): '''Load SWOT swath and Nadir data for file sgridfile ''' # Load SWOT swath file sgrid = rw_data.Sat_SWOT(nfile=sgridfile) cycle = 0 x_al = [] x_ac = [] al_cycle = 0 timeshift = 0 sgrid.load_swath(cycle=cycle, x_al=x_al, x_ac=x_ac, al_cycle=al_cycle, timeshift=timeshift) sgrid.loncirc = numpy.rad2deg(numpy.unwrap(sgrid.lon)) # Extract the pass number from the file name ipass = int(sgridfile[-6: -3]) sgrid.ipass = ipass return sgrid
def save_SWOT(cycle, sgrid, err, p, mask_land, time=[], vindice=[], SSH_true=[], save_var='all'): ofile = '{}_c{:02d}_p{:03d}.nc'.format(p.file_output, cycle + 1, sgrid.ipass) OutputSWOT = rw_data.Sat_SWOT(nfile=ofile, lon=(sgrid.lon+360) % 360, lat=sgrid.lat, time=time, x_ac=sgrid.x_ac, x_al=sgrid.x_al, cycle=sgrid.cycle, lon_nadir=(sgrid.lon_nadir+360) % 360, lat_nadir=sgrid.lat_nadir) OutputSWOT.gridfile = sgrid.gridfile err.SSH2 = err.SSH if save_var == 'all': all_var = make_empty_vars(sgrid) beam_pos = (12, 47) tmp_var = + err.SSH flag = make_flags(tmp_var, sgrid, p.modelbox, beam_pos) all_var['karin_surf_type'] = mask_land all_var['ssh_karin_swath'] = + err.SSH else: all_var = None err.SSH2 = None flag = None if save_var == 'expert': OutputSWOT.write_data(SSH_model=SSH_true, index=vindice, roll_err_1d=err.roll1d, phase_err_1d=err.phase1d, bd_err_1d=err.baseline_dilation1d, ssb_err=err.ssb, karin_err=err.karin, pd_err_1b=err.wet_tropo1, pd_err_2b=err.wet_tropo2, pd=err.wt, timing_err_1d=err.timing1d) else: OutputSWOT.write_data(SSH_model=SSH_true, index=vindice, roll_err=err.roll, bd_err=err.baseline_dilation, phase_err=err.phase, ssb_err=err.ssb, karin_err=err.karin, pd_err_1b=err.wet_tropo1, pd_err_2b=err.wet_tropo2, pd=err.wt, timing_err=err.timing, SSH_obs=err.SSH, empty_var=all_var) return None
import swotsimulator.rw_data as rw_data import numpy import params as p filegrid = p.indatadir + 'OREGON_grd.nc' fileswot = p.outdatadir + 'OREGON_swot292_c01_p024.nc' vmin = -0.01 vmax = 0.01 fig, axes = plt.subplots(figsize=(30, 20), nrows=2, ncols=1, sharex=True, sharey=False) tloc = 0.11 tfont = 24 data = rw_data.Sat_SWOT(file=fileswot) data.load_swath(pd_err_2b=[], pd=[], x_ac=[], x_al=[]) x_al, x_ac = numpy.meshgrid(data.x_al, data.x_ac) x_al = x_al - numpy.min(numpy.min(x_al)) ax = axes[0] SSH = data.pd_err_2b stitle = '(a) 1 beam residual error along swath' nac = numpy.shape(data.lon)[1] SSH[abs(SSH) > 1000] = numpy.nan norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax) SSH[SSH == 0] = numpy.nan SSH = numpy.ma.array(SSH, mask=numpy.isnan(SSH)) print(numpy.shape(x_al), numpy.shape(x_ac), numpy.shape(SSH)) col = ax.pcolormesh(x_al[(nac / 2), :], x_ac[:int(nac / 2), 0], numpy.transpose(SSH[:, :int(nac / 2)]),
import params as p import swotsimulator.rw_data as rw_data dirname = p.outdatadir rootname = p.file_output dx = p.delta_al #km listfile = glob.glob(p.file_output + '_c*' + '_p*.nc') nr = 0 distance_min = 400 f0 = numpy.linspace(1 / distance_min * dx, 1 / 2 - 1 / distance_min * dx, num=int(distance_min / dx / 2.)) for coordfile in listfile: print(coordfile) data = rw_data.Sat_SWOT(file=coordfile) data.load_swath(SSH_obs=[], SSH_model=[]) nal, nac = numpy.shape(data.SSH_obs) for iac in range(nac): if nal * dx >= distance_min: tap = 0.04 ff, PSD_obs = myspectools.psd1d(hh=data.SSH_obs[:, iac], dx=dx, detrend=True, tap=tap) ff, PSD_model = myspectools.psd1d(hh=data.SSH_model[:, iac], dx=dx, detrend=True, tap=tap)
def worker_method_grid(*args, **kwargs): #_args = list(args)# [0] #msg_queue = _args.pop() #ipass = _args[0] msg_queue, ipass, p2, passtime, stime = args[:5] x_al, x_ac, tcycle, al_cycle, nhalfswath, lon, lat, timeshift = args[5:] p = mod_tools.fromdict(p2) npoints = 1 sat_elev = p.sat_elev if sat_elev is None: sat_elev = const.sat_elev # Detect indices corresponding to the pass if ipass == numpy.shape(passtime)[0] - 1: ind = numpy.where((stime >= passtime[ipass]))[0] else: ind = numpy.where((stime >= passtime[ipass]) & (stime < passtime[ipass + 1]))[0] nind = numpy.shape(ind)[0] # Compute swath grid if pass is in the subdomain if nind > 5: # pstep = float(ipass + 1) / float(numpy.shape(passtime)[0]) # str1 = 'selected pass: {}'.format(ipass + 1) # mod_tools.update_progress(pstep, str1, None) # Initialize SWOT grid, grid variables and Satellite # direction and Location filesgrid = '{}_p{:03d}.nc'.format(p.filesgrid, ipass + 1) sgrid = rw_data.Sat_SWOT(nfile=filesgrid) sgrid.x_al = x_al[ind] sgrid.x_ac = x_ac sgrid.cycle = tcycle sgrid.al_cycle = al_cycle sgrid.time = stime[ind] sgrid.lon = numpy.zeros((nind, 2 * nhalfswath)) sgrid.lat = numpy.zeros((nind, 2 * nhalfswath)) SatDir = numpy.zeros((int(nind / npoints), 3)) SatLoc = numpy.zeros((int((nind) / npoints), 3)) # Initialize Nadir track, grid variables filengrid = '{}nadir_p{:03d}.nc'.format(p.filesgrid, ipass + 1) ngrid = rw_data.Sat_nadir(nfile=filengrid) ngrid.x_al = x_al[ind] ngrid.cycle = tcycle ngrid.al_cycle = al_cycle ngrid.time = stime[ind] # Project in cartesian coordinates satellite ground location s2cart = mod_tools.spher2cart(lon[ind[0]:ind[-1] + 1:npoints], lat[ind[0]:ind[-1] + 1:npoints]) SatLoc[:, 0], SatLoc[:, 1], SatLoc[:, 2] = s2cart # Compute satellite direction (SatLoc is periodic) SatDir[1:-1, 0] = ((SatLoc[2:, 0] - SatLoc[:-2, 0]) / numpy.sqrt(SatLoc[1:-1, 0]**2 + SatLoc[1:-1, 1]**2 + SatLoc[1:-1, 2]**2)) SatDir[1:-1, 1] = ((SatLoc[2:, 1] - SatLoc[:-2, 1]) / numpy.sqrt(SatLoc[1:-1, 0]**2 + SatLoc[1:-1, 1]**2 + SatLoc[1:-1, 2]**2)) SatDir[1:-1, 2] = ((SatLoc[2:, 2] - SatLoc[:-2, 2]) / numpy.sqrt(SatLoc[1:-1, 0]**2 + SatLoc[1:-1, 1]**2 + SatLoc[1:-1, 2]**2)) SatDir[-1, :] = SatDir[-2, :] SatDir[0, :] = SatDir[1, :] # Rotate from earth center around satellite direction to compute # swath points of angles between the borders of the swath in left # and right swath for i in range(0, nind, npoints): for j in range(0, int(nhalfswath)): R = mod_tools.rotationmat3D( float((j * p.delta_ac + p.halfgap) / (const.Rearth * 10**-3)), SatDir[int(i / npoints), :]) ObsLoc = numpy.dot(R, SatLoc[int(i / npoints)]) cs = mod_tools.cart2spher(ObsLoc[0], ObsLoc[1], ObsLoc[2]) sgrid.lon[i, nhalfswath + j], sgrid.lat[i, nhalfswath + j] = cs ObsLoc = numpy.dot(numpy.transpose(R), SatLoc[int(i / npoints)]) cs = mod_tools.cart2spher(ObsLoc[0], ObsLoc[1], ObsLoc[2]) sgrid.lon[i, nhalfswath - j - 1], sgrid.lat[i, nhalfswath - j - 1] = cs if npoints > p.delta_al: if i >= npoints: lon1 = +sgrid.lon[i - npoints, nhalfswath + j] lon2 = +sgrid.lon[i, nhalfswath + j] _lon = numpy.arange(lon1, lon2, (lon2 - lon1) / npoints) sgrid.lon[i - npoints:i, nhalfswath + j] = _lon lat1 = +sgrid.lat[i - npoints, nhalfswath + j] lat2 = +sgrid.lat[i, nhalfswath + j] _lat = numpy.arange(lat1, lat2, (lat2 - lat1) / npoints) sgrid.lat[i - npoints:i, nhalfswath + j] = _lat # if npoints>p.delta_al: # for j in range(0, 2*int(nhalfswath+1)): # sgrid.lon[:,j]=numpy.arange(sgrid.lon[0,j], sgrid.lon[ind[-1],j], # (sgrid.lon[-1,j]-sgrid.lon[0,j])/npoints) # sgrid.lat[:,j]=numpy.arange(sgrid.lat[0,j], sgrid.lat[-1,j], # (sgrid.lat[-1,j]-sgrid.lat[0,j])/npoints) # Save Sgrid object sgrid.timeshift = timeshift ngrid.timeshift = timeshift ngrid.lon = (lon[ind] + 360) % 360 ngrid.lat = lat[ind] sgrid.lon_nadir = (lon[ind] + 360) % 360 sgrid.lat_nadir = lat[ind] # Remove grid file if it exists and save it if os.path.exists(filesgrid): os.remove(filesgrid) sgrid.first_time = p.first_time sgrid.write_swath() if p.nadir: if os.path.exists(filengrid): os.remove(filengrid) ngrid.first_time = p.first_time ngrid.write_orb() msg_queue.put((os.getpid(), ipass, None, None)) return None
def orbit2swath(modelbox, p, orb): '''Computes the swath of SWOT satellites on a subdomain from an orbit. The path of the satellite is given by the orbit file and the subdomain corresponds to the one in the model. Note that a subdomain can be manually added in the parameters file. \n Inputs are satellite orbit (p.filesat), subdomain (modelbox), Swath parameters (half gap distance p.halfgap, half swath distance p.halfswath, along track resolution p.delta_al, across track resolution p.delta_ac). \n Outputs are netcdf files containing SWOT grid (along track distance x_al, across track distance from nadir x_ac, longitude lon and latitude lat, number of days in a cycle cycle, distance crossed in a cycle cycle_al, time''' ''' Compute orbit from Swath ''' # - Load altimeter orbit npoints = 1 x_al = orb.x_al stime = orb.time lon = orb.lon lat = orb.lat tcycle = orb.cycle al_cycle = orb.al_cycle passtime = orb.passtime # - Compute accross track distances from nadir # Number of points in half of the swath nhalfswath = int((p.halfswath-p.halfgap)/p.delta_ac) + 1 # Across track distance from nadir x_ac = numpy.zeros((2*nhalfswath)) for i in range(0, int(nhalfswath)): x_ac[i] = -(nhalfswath - i)*p.delta_ac - p.halfgap + p.delta_ac x_ac[i + nhalfswath] = i * p.delta_ac + p.halfgap # - Computation of SWOT grid and storage by passes logger.info('\n Compute SWOT grid') # Detect first pass that is in the subdomain ipass0 = 0 # strpass = [] # Loop on all passes after the first pass detected for ipass in range(ipass0, numpy.shape(passtime)[0]): # Detect indices corresponding to the pass if ipass == numpy.shape(passtime)[0]-1: ind = numpy.where((stime >= passtime[ipass]))[0] else: ind = numpy.where((stime >= passtime[ipass]) & (stime < passtime[ipass+1]))[0] nind = numpy.shape(ind)[0] # Compute swath grid if pass is in the subdomain if nind > 5: pstep = float(ipass + 1) / float(numpy.shape(passtime)[0]) str1 = 'selected pass: {}'.format(ipass + 1) mod_tools.update_progress(pstep, str1, None) # Initialize SWOT grid, grid variables and Satellite # direction and Location filesgrid = '{}_p{:03d}.nc'.format(p.filesgrid,ipass + 1) sgrid = rw_data.Sat_SWOT(nfile=filesgrid) sgrid.x_al = x_al[ind] sgrid.x_ac = x_ac sgrid.cycle = tcycle sgrid.al_cycle = al_cycle sgrid.time = stime[ind] sgrid.lon = numpy.zeros((nind, 2*nhalfswath)) sgrid.lat = numpy.zeros((nind, 2*nhalfswath)) SatDir = numpy.zeros((int(nind/npoints), 3)) SatLoc = numpy.zeros((int((nind)/npoints), 3)) # Initialize Nadir track, grid variables filengrid = '{}nadir_p{:03d}.nc'.format(p.filesgrid,ipass + 1) ngrid = rw_data.Sat_nadir(nfile=filengrid) ngrid.x_al = x_al[ind] ngrid.cycle = tcycle ngrid.al_cycle = al_cycle ngrid.time = stime[ind] # Project in cartesian coordinates satellite ground location s2cart = mod_tools.spher2cart(lon[ind[0]: ind[-1]+1: npoints], lat[ind[0]: ind[-1]+1: npoints]) SatLoc[:, 0], SatLoc[:, 1], SatLoc[:, 2] = s2cart # Compute satellite direction (SatLoc is periodic) SatDir[1: -1, 0] = ((SatLoc[2:, 0] - SatLoc[: -2, 0]) / numpy.sqrt(SatLoc[1: -1, 0]**2 + SatLoc[1: -1, 1]**2 + SatLoc[1: -1, 2]**2)) SatDir[1: -1, 1] = ((SatLoc[2:, 1] - SatLoc[: -2, 1]) / numpy.sqrt(SatLoc[1: -1, 0]**2 + SatLoc[1: -1, 1]**2 + SatLoc[1: -1, 2]**2)) SatDir[1: -1, 2] = ((SatLoc[2:, 2] - SatLoc[: -2, 2]) / numpy.sqrt(SatLoc[1: -1, 0]**2 + SatLoc[1: -1, 1]**2 + SatLoc[1: -1, 2]**2)) SatDir[-1, :] = SatDir[-2, :] SatDir[0, :] = SatDir[1, :] # Rotate from earth center around satellite direction to compute # swath points of angles between the borders of the swath in left # and right swath for i in range(0, nind, npoints): for j in range(0, int(nhalfswath)): R = mod_tools.rotationmat3D(float((j*p.delta_ac+p.halfgap) / (const.Rearth*10**-3)), SatDir[int(i/npoints), :]) ObsLoc = numpy.dot(R, SatLoc[int(i/npoints)]) cs = mod_tools.cart2spher(ObsLoc[0], ObsLoc[1], ObsLoc[2]) sgrid.lon[i, nhalfswath+j], sgrid.lat[i, nhalfswath+j] = cs ObsLoc = numpy.dot(numpy.transpose(R), SatLoc[int(i/npoints)]) cs = mod_tools.cart2spher(ObsLoc[0], ObsLoc[1], ObsLoc[2]) sgrid.lon[i, nhalfswath-j-1], sgrid.lat[i, nhalfswath-j-1] = cs if npoints > p.delta_al: if i >= npoints: sgrid.lon[i-npoints: i, nhalfswath+j] = numpy.arange(sgrid.lon[i-npoints, nhalfswath+j], sgrid.lon[i, nhalfswath+j], (sgrid.lon[i, nhalfswath+j]-sgrid.lon[i-npoints, nhalfswath+j])/npoints) sgrid.lat[i-npoints: i, nhalfswath+j] = numpy.arange(sgrid.lat[i-npoints, nhalfswath+j], sgrid.lat[i, nhalfswath+j], (sgrid.lat[i, nhalfswath+j]-sgrid.lat[i-npoints, nhalfswath+j])/npoints) # if npoints>p.delta_al: # print 'interp not coded' # for j in range(0, 2*int(nhalfswath+1)): # sgrid.lon[:,j]=numpy.arange(sgrid.lon[0,j], sgrid.lon[ind[-1],j], # (sgrid.lon[-1,j]-sgrid.lon[0,j])/npoints) # sgrid.lat[:,j]=numpy.arange(sgrid.lat[0,j], sgrid.lat[-1,j], # (sgrid.lat[-1,j]-sgrid.lat[0,j])/npoints) # Save Sgrid object sgrid.timeshift = orb.timeshift ngrid.timeshift = orb.timeshift ngrid.lon = (lon[ind] + 360) % 360 ngrid.lat = lat[ind] sgrid.lon_nadir = (lon[ind] + 360) % 360 sgrid.lat_nadir = lat[ind] # Remove grid file if it exists and save it if os.path.exists(filesgrid): os.remove(filesgrid) sgrid.write_swath() if p.nadir: if os.path.exists(filengrid): os.remove(filengrid) ngrid.write_orb() mod_tools.update_progress(1, 'All swaths have been processed', ' ') return None
def orbit2swath(modelbox, p,orb): # -- Load altimeter orbit npoints=1 x_al=orb.x_al stime=orb.time lon=orb.lon lat=orb.lat tcycle=orb.cycle al_cycle=orb.al_cycle passtime=orb.passtime ## -- Compute accross track distances from nadir # Number of points in half of the swath nhalfswath=int( (p.halfswath-p.halfgap)/p.delta_ac) +1 # Across track distance from nadir x_ac=numpy.zeros((2*nhalfswath)) for i in range(0, int(nhalfswath)): x_ac[i]=-(nhalfswath-i)*p.delta_ac-p.halfgap+p.delta_ac x_ac[i+nhalfswath]=i*p.delta_ac+p.halfgap ## -- Computation of SWOT grid and storage by passes print('\n Compute SWOT grid') # Detect first pass that is in the subdomain ipass0=0 strpass=[] # Loop on all passes after the first pass detected for ipass in range(ipass0,numpy.shape(passtime)[0]): # Detect indices corresponding to the pass if ipass==numpy.shape(passtime)[0]-1: ind=numpy.where((stime>=passtime[ipass]))[0] else: ind=numpy.where((stime>=passtime[ipass]) & (stime<passtime[ipass+1]))[0] nind=numpy.shape(ind)[0] # Compute swath grid if pass is in the subdomain if nind>5: mod_tools.update_progress(float(ipass+1)/float(numpy.shape(passtime)[0]), 'selected pass: '******'_p'+str(ipass+1).zfill(3)+'.nc' sgrid=rw_data.Sat_SWOT(file=filesgrid) sgrid.x_al=x_al[ind] sgrid.x_ac=x_ac sgrid.cycle=tcycle sgrid.al_cycle=al_cycle sgrid.time=stime[ind] sgrid.lon=numpy.zeros((nind,2*nhalfswath)) sgrid.lat=numpy.zeros((nind,2*nhalfswath)) SatDir=numpy.zeros((int(nind/npoints),3)) SatLoc=numpy.zeros((int((nind)/npoints),3)) # Initialize Nadir track, grid variables filengrid=p.filesgrid+'nadir_p'+str(ipass+1).zfill(3)+'.nc' ngrid=rw_data.Sat_nadir(file=filengrid) ngrid.x_al=x_al[ind] ngrid.cycle=tcycle ngrid.al_cycle=al_cycle ngrid.time=stime[ind] ## Project in cartesian coordinates satellite ground location #SatLoc[:,0], SatLoc[:,1], SatLoc[:,2]=mod_tools.spher2cart(lon[ind[0]:ind[-1]+npoints:npoints], lat[ind[0]:ind[-1]+npoints:npoints]) #if numpy.min(lon[ind[0]:ind[-1]+1])<1. and numpy.max(lon[ind[0]:ind[-1]+1])>359.: #lontmp=lon[ind[0]:ind[-1]+1] #lontmp[numpy.where(lontmp>180.)]=lontmp[numpy.where(lontmp>180.)]-360. SatLoc[:,0], SatLoc[:,1], SatLoc[:,2]=mod_tools.spher2cart(lon[ind[0]:ind[-1]+1:npoints], lat[ind[0]:ind[-1]+1:npoints]) ## Compute satellite direction (SatLoc is periodic) SatDir[1:-1,0]=(SatLoc[2:,0]-SatLoc[:-2,0])/numpy.sqrt(SatLoc[1:-1,0]**2+SatLoc[1:-1,1]**2+SatLoc[1:-1,2]**2) SatDir[1:-1,1]=(SatLoc[2:,1]-SatLoc[:-2,1])/numpy.sqrt(SatLoc[1:-1,0]**2+SatLoc[1:-1,1]**2+SatLoc[1:-1,2]**2) SatDir[1:-1,2]=(SatLoc[2:,2]-SatLoc[:-2,2])/numpy.sqrt(SatLoc[1:-1,0]**2+SatLoc[1:-1,1]**2+SatLoc[1:-1,2]**2) SatDir[-1]=SatDir[-2] SatDir[0]=SatDir[1] ## Rotate from earth center around satellite direction to compute swath points of angles between the borders of the swath in left and right swath for i in range(0, nind, npoints): for j in range(0, int(nhalfswath)): R=mod_tools.rotationmat3D(float((j*p.delta_ac + p.halfgap)/(const.Rearth*10**-3)) , SatDir[int(i/npoints),:]) ObsLoc=numpy.dot(R,SatLoc[int(i/npoints)]) sgrid.lon[i,nhalfswath+j], sgrid.lat[i, nhalfswath+j]=mod_tools.cart2spher(ObsLoc[0], ObsLoc[1], ObsLoc[2]) ObsLoc=numpy.dot(numpy.transpose(R),SatLoc[int(i/npoints)]) sgrid.lon[i,nhalfswath-j-1], sgrid.lat[i, nhalfswath-j-1]=mod_tools.cart2spher(ObsLoc[0], ObsLoc[1], ObsLoc[2]) if npoints>p.delta_al: if i>=npoints: sgrid.lon[i-npoints:i, nhalfswath+j]=numpy.arange(sgrid.lon[i-npoints,nhalfswath+j], sgrid.lon[i,nhalfswath+j], (sgrid.lon[i,nhalfswath+j]-sgrid.lon[i-npoints,nhalfswath+j])/npoints) sgrid.lat[i-npoints:i,nhalfswath+j]=numpy.arange(sgrid.lat[i-npoints,nhalfswath+j], sgrid.lat[i,nhalfswath+j], (sgrid.lat[i,nhalfswath+j]-sgrid.lat[i-npoints,nhalfswath+j])/npoints) #if npoints>p.delta_al: #print 'interp not coded' #for j in range(0, 2*int(nhalfswath+1)): #sgrid.lon[:,j]=numpy.arange(sgrid.lon[0,j], sgrid.lon[ind[-1],j], (sgrid.lon[-1,j]-sgrid.lon[0,j])/npoints) #sgrid.lat[:,j]=numpy.arange(sgrid.lat[0,j], sgrid.lat[-1,j], (sgrid.lat[-1,j]-sgrid.lat[0,j])/npoints) sgrid.timeshift=orb.timeshift ngrid.timeshift=orb.timeshift ngrid.lon=(lon[ind]+360)%360 ngrid.lat=lat[ind] sgrid.lon_nadir=(lon[ind]+360)%360 sgrid.lat_nadir=lat[ind] if os.path.exists(filesgrid): os.remove(filesgrid) sgrid.write_swath() if p.nadir: if os.path.exists(filengrid): os.remove(filengrid) ngrid.write_orb() mod_tools.update_progress(1, 'All swaths have been processed', ' ') return None
import params as p import swotsimulator.rw_data as rw_data dirname = p.outdatadir rootname = p.file_output dx = p.delta_al #km listfile = glob.glob(p.file_output + '_c*' + '_p*.nc') nr = 0 for ifile in listfile: print(ifile) hh_roll = [] hh_phase = [] hh_bd = [] hh_timing = [] data = rw_data.Sat_SWOT(nfile=ifile) data.load_swath(wt=[], wt_err=[]) nal, nac = numpy.shape(data.roll_err) if nal * dx >= distance_min: f0 = numpy.linspace(1 / distance_min * dx, 1 / 2 - 1 / distance_min * dx, num=int(distance_min / dx / 2.)) tap = 0.04 if p.roll: ff, PSD_roll = myspectools.psd1d(hh=data.roll_err, dx=dx, detrend=True, tap=tap) if p.phase: ff, PSD_phase = myspectools.psd1d(hh=data.phase_err,