示例#1
0
def get_scene():
    sc = Scene()
    sc.frame.llLat = 52.395833
    sc.frame.llLon = 13.061389
    sc.frame.dE = 0.001
    sc.frame.dN = 0.001
    sc.frame.spacing = "degree"
    sc.displacement = num.zeros((500, 500))

    return sc
示例#2
0
def save_kite(inps):
    """save kite"""
    # read mintpy data
    date1, date2, disp, disp_atr, incidence, azimuth = read_HDFEOS(inps)

    # subset data based on bbox
    if inps.SNWE:
        print('Subset data based on bbox')
        lat_user, lon_user, row, sample, rows,samples = extract_data_based_bbox(inps)
        disp = disp[row: row+rows, sample: sample+samples]
        incidence = incidence[row: row+rows, sample: sample+samples]
        azimuth = azimuth[row: row+rows, sample: sample+samples]
    
    # convert to head angle
    print('convert azimuth angle to head angle')
    head = ut.azimuth2heading_angle(azimuth)
    phi = -head + 180

    # convert degree to radian
    incidence *= np.pi/180
    phi *= np.pi/180

    sc = Scene()
    # flip up-down of displacement and angle matrix
    sc.displacement = np.flipud(disp)
    
    sc.theta = np.flipud(incidence)
    sc.phi = np.flipud(phi)
    # calculate the scene's frame lower left corner, in geographical coordinate
    lon_ul = float(disp_atr['X_FIRST'])
    lat_ul = float(disp_atr['Y_FIRST'])

    lat_step = float(disp_atr['Y_STEP'])
    length = int(disp_atr['LENGTH'])

    lat_ll = lat_ul + lat_step * length
    lon_ll = lon_ul
 
    if inps.SNWE:
        lat_ll = lat_user 
        lon_ll = lon_user

    sc.frame.llLat = lat_ll
    sc.frame.llLon = lon_ll

    # the pixel spacing can be either 'meter' or 'degree'
    sc.frame.spacing = disp_atr['X_UNIT'][:-1]
    sc.frame.dN = float(disp_atr['Y_STEP']) * (-1)
    sc.frame.dE = float(disp_atr['X_STEP'])

    # Saving the scene
    print('write Kite scene')
    if inps.outfile is not None:
        kite_outfile = inps.outfile[0]
    else:
        if inps.velocity:
            data_type = 'vel'
        else:
            data_type = 'dis'
        if inps.SNWE is not None:
            kite_outfile = inps.input_HDFEOS[0].split('.')[0] + '_' + str(date1) + '_' + str(date2) + '_' + data_type + '_subset'
        else:
            kite_outfile = inps.input_HDFEOS[0].split('.')[0] + '_' + str(date1) + '_' + str(date2) + '_' + data_type

    sc.save(kite_outfile)
示例#3
0
print('Av. Heading:', np.nanmean(heading))
print('Av Look:', np.nanmean(look))

theta = np.deg2rad(90. - look)
phi = np.ones((ds.RasterYSize, ds.RasterXSize)) * np.deg2rad(-90 - heading)

print('Av. theta:', np.rad2deg(np.nanmean(theta)))
print('Av phi:', np.rad2deg(np.nanmean(phi)))

# sys.exit()
#los[np.isnan(los)]=0.0
#theta[np.isnan(theta)]=0.0
#phi[np.isnan(phi)]=0.0

sc = Scene()
sc.displacement = -los
# !!! lower left corner !!!
sc.frame.llLat = ds_geo[3] + ds_geo[5] * ds.RasterYSize
sc.frame.llLon = ds_geo[0]

sc.frame.dN = -ds_geo[5]
sc.frame.dE = ds_geo[1]
sc.frame.spacing = 'degree'

sc.theta = theta
sc.phi = phi

sc.meta.scene_id = arguments["--id"]

#get ref point
print(sc.frame.llEutm, sc.frame.llNutm)