Esempio n. 1
0
def focus(frame, amb=0.0, dop=None):
    from isceobj.Catalog import recordInputsAndOutputs
    from iscesys.ImageUtil.ImageUtil import ImageUtil as IU
    from isceobj.Constants import SPEED_OF_LIGHT

    raw_r0 = frame.startingRange
    raw_dr = frame.getInstrument().getRangePixelSize()
    img = frame.getImage()
    if dop is None:
        dop = frame._dopplerVsPixel

    print('dop', dop)

    #####Velocity/ acceleration etc
    planet = frame.instrument.platform.planet
    elp = copy.copy(planet.ellipsoid)
    svmid = frame.orbit.interpolateOrbit(frame.sensingMid, method='hermite')
    xyz = svmid.getPosition()
    vxyz = svmid.getVelocity()
    llh = elp.xyz_to_llh(xyz)

    heading = frame.orbit.getENUHeading(frame.sensingMid)
    print('Heading: ', heading)

    elp.setSCH(llh[0], llh[1], heading)
    sch, schvel = elp.xyzdot_to_schdot(xyz, vxyz)
    vel = np.linalg.norm(schvel)
    hgt = sch[2]
    radius = elp.pegRadCur

    ####Computation of acceleration
    dist = np.linalg.norm(xyz)
    r_spinvec = np.array([0., 0., planet.spin])
    r_tempv = np.cross(r_spinvec, xyz)

    inert_acc = np.array([-planet.GM * x / (dist**3) for x in xyz])

    r_tempa = np.cross(r_spinvec, vxyz)
    r_tempvec = np.cross(r_spinvec, r_tempv)

    r_bodyacc = inert_acc - 2 * r_tempa - r_tempvec
    schbasis = elp.schbasis(sch)

    schacc = np.dot(schbasis.xyz_to_sch, r_bodyacc).tolist()[0]

    print('SCH velocity: ', schvel)
    print('SCH acceleration: ', schacc)
    print('Body velocity: ', vel)
    print('Height: ', hgt)
    print('Radius: ', radius)

    #####Setting up formslc

    form = FormSLC()
    form.configure()

    ####Width
    form.numberBytesPerLine = img.getWidth()

    ###Includes header
    form.numberGoodBytes = img.getWidth()

    ####Different chirp extensions
    #    form.nearRangeChirpExtFrac = 0.0
    #    form.farRangeChirpExtFrac = 0.0
    #    form.earlyAzimuthChirpExtFrac = 0.0
    #    form.lateAzimuthChirpExtrFrac = 0.0

    ###First Line - set with defaults
    ###Depending on extensions
    #    form.firstLine = 0

    ####First Sample
    form.firstSample = img.getXmin() // 2

    ####Start range bin - set with defaults
    ###Depending on extensions
    #    form.startRangeBin = 1

    ####Starting range
    form.rangeFirstSample = frame.startingRange

    ####Number range bin
    ###Determined in FormSLC.py using chirp extensions
    #    form.numberRangeBin = img.getWidth() // 2 - 1000

    ####Azimuth looks
    form.numberAzimuthLooks = 1

    ####debug
    form.debugFlag = False

    ####PRF
    form.prf = frame.PRF
    form.sensingStart = frame.sensingStart

    ####Bias
    form.inPhaseValue = frame.getInstrument().inPhaseValue
    form.quadratureValue = frame.getInstrument().quadratureValue

    ####Resolution
    form.antennaLength = frame.instrument.platform.antennaLength
    form.azimuthResolution = 0.6 * form.antennaLength  #85% of max bandwidth
    ####Sampling rate
    form.rangeSamplingRate = frame.getInstrument().rangeSamplingRate

    ####Chirp parameters
    form.chirpSlope = frame.getInstrument().chirpSlope
    form.rangePulseDuration = frame.getInstrument().pulseLength

    ####Wavelength
    form.radarWavelength = frame.getInstrument().radarWavelength

    ####Secondary range migration
    form.secondaryRangeMigrationFlag = False

    ###pointing direction
    form.pointingDirection = frame.instrument.platform.pointingDirection
    print('Lookside: ', form.pointingDirection)

    ####Doppler centroids
    cfs = [amb, 0., 0., 0.]
    for ii in range(min(len(dop), 4)):
        cfs[ii] += dop[ii] / form.prf

    form.dopplerCentroidCoefficients = cfs

    ####Create raw image
    rawimg = isceobj.createRawImage()
    rawimg.load(img.filename + '.xml')
    rawimg.setAccessMode('READ')
    rawimg.createImage()

    form.rawImage = rawimg

    ####All the orbit parameters
    form.antennaSCHVelocity = schvel
    form.antennaSCHAcceleration = schacc
    form.bodyFixedVelocity = vel
    form.spacecraftHeight = hgt
    form.planetLocalRadius = radius

    ###Create SLC image
    slcImg = isceobj.createSlcImage()
    slcImg.setFilename(img.filename + '.slc')
    form.slcImage = slcImg

    form.formslc()

    return form
Esempio n. 2
0
def main():
    
    # create FormSLC object and initilaize it using FormSLC930110.xml. it actually contains all the parameters already except the raw and slc images.
    # one could use the Platform and Radar objects to change some of the parameters.
    obj = FormSLC()
    initfileForm = 'FormSCL930110.xml'
    #instantiate a InitFromXmlFile object passinf the file name in the contructor
    fileInit = InitFromXmlFile(initfileForm)
    # init FormSLC by passing the init object
    obj.initComponent(fileInit)
    
    
    initfilePl = 'Platform930110.xml'
    fileInit = InitFromXmlFile(initfilePl)
    objPl = Platform()
    objPl.initComponent(fileInit)
    
    #instantiate a InitFromObject object passing the object from which to initialize in the contructor
    objInit = InitFromObject(objPl)
    obj.initComponent(objInit)
    
    initfileRadar = 'Radar930110.xml'
    fileInit = InitFromXmlFile(initfileRadar)
    objRadar = Radar()
    objRadar.initComponent(fileInit)
    
    objInit = InitFromObject(objRadar)
    obj.initComponent(objInit)
    obj.printComponent()    
    filename = "930110.raw"
    accessmode = 'read'
    endian = 'l'
    width = 11812 
    
    objRaw = RawImage()
    # only sets the parameter
    objRaw.initImage(filename,accessmode,endian,width)
    # it actually creates the C++ object
    objRaw.createImage()
    
    filenameSLC ="930110.slc"
    accessmode = 'write'
    endian = 'l'
    width = 5700
    
    dict = {'FILE_NAME':filenameSLC,'ACCESS_MODE':accessmode,'BYTE_ORDER':endian,'WIDTH':width}
    dictInit = InitFromDictionary(dict)
    objSlc = SlcImage()
    
    objSlc.initComponent(dictInit)
    objSlc.createImage()
   
    
    obj.formSLCImage(objRaw,objSlc)
    #call this to do some cleaning. always call it if initImage (or the initComponent) was called
    objSlc.finalizeImage()
    objRaw.finalizeImage()
Esempio n. 3
0
def focus(frame, outname, amb=0.0):
    from isceobj.Catalog import recordInputsAndOutputs
    from iscesys.ImageUtil.ImageUtil import ImageUtil as IU
    from isceobj.Constants import SPEED_OF_LIGHT

    raw_r0 = frame.startingRange
    raw_dr = frame.getInstrument().getRangePixelSize()
    img = frame.getImage()
    dop = frame._dopplerVsPixel
    #dop = [x/frame.PRF for x in frame._dopplerVsPixel]

    #####Velocity/ acceleration etc
    planet = frame.instrument.platform.planet
    elp = copy.copy(planet.ellipsoid)
    svmid = frame.orbit.interpolateOrbit(frame.sensingMid, method='hermite')
    xyz = svmid.getPosition()
    vxyz = svmid.getVelocity()
    llh = elp.xyz_to_llh(xyz)

    heading = frame.orbit.getENUHeading(frame.sensingMid)
    print('Heading: ', heading)

    elp.setSCH(llh[0], llh[1], heading)
    sch, schvel = elp.xyzdot_to_schdot(xyz, vxyz)
    vel = np.linalg.norm(schvel)
    hgt = sch[2]
    radius = elp.pegRadCur

    ####Computation of acceleration
    dist = np.linalg.norm(xyz)
    r_spinvec = np.array([0., 0., planet.spin])
    r_tempv = np.cross(r_spinvec, xyz)

    inert_acc = np.array([-planet.GM * x / (dist**3) for x in xyz])

    r_tempa = np.cross(r_spinvec, vxyz)
    r_tempvec = np.cross(r_spinvec, r_tempv)

    r_bodyacc = inert_acc - 2 * r_tempa - r_tempvec
    schbasis = elp.schbasis(sch)

    schacc = np.dot(schbasis.xyz_to_sch, r_bodyacc).tolist()[0]

    print('SCH velocity: ', schvel)
    print('SCH acceleration: ', schacc)
    print('Body velocity: ', vel)
    print('Height: ', hgt)
    print('Radius: ', radius)

    #####Setting up formslc

    form = FormSLC()
    form.configure()

    ####Width
    form.numberBytesPerLine = img.getWidth()

    ###Includes header
    form.numberGoodBytes = img.getWidth()

    ####First Sample
    form.firstSample = img.getXmin() // 2

    ####Starting range
    form.rangeFirstSample = frame.startingRange

    ####Azimuth looks
    form.numberAzimuthLooks = 1

    ####debug
    form.debugFlag = False

    ####PRF
    form.prf = frame.PRF
    form.sensingStart = frame.sensingStart

    ####Bias
    form.inPhaseValue = frame.getInstrument().inPhaseValue
    form.quadratureValue = frame.getInstrument().quadratureValue

    ####Resolution
    form.antennaLength = frame.instrument.platform.antennaLength
    form.azimuthResolution = 0.6 * form.antennaLength  #85% of max bandwidth

    ####Sampling rate
    form.rangeSamplingRate = frame.getInstrument().rangeSamplingRate

    ####Chirp parameters
    form.chirpSlope = frame.getInstrument().chirpSlope
    form.rangePulseDuration = frame.getInstrument().pulseLength

    ####Wavelength
    form.radarWavelength = frame.getInstrument().radarWavelength

    ####Secondary range migration
    form.secondaryRangeMigrationFlag = False

    ###pointing direction
    form.pointingDirection = frame.instrument.platform.pointingDirection
    print('Lookside: ', form.pointingDirection)

    ####Doppler centroids
    cfs = [amb, 0., 0., 0.]
    for ii in range(min(len(dop), 4)):
        cfs[ii] += dop[ii] / form.prf

    form.dopplerCentroidCoefficients = cfs

    ####Create raw image
    rawimg = isceobj.createRawImage()
    rawimg.load(img.filename + '.xml')
    rawimg.setAccessMode('READ')
    rawimg.createImage()

    form.rawImage = rawimg

    ####All the orbit parameters
    form.antennaSCHVelocity = schvel
    form.antennaSCHAcceleration = schacc
    form.bodyFixedVelocity = vel
    form.spacecraftHeight = hgt
    form.planetLocalRadius = radius

    ###Create SLC image
    slcImg = isceobj.createSlcImage()
    slcImg.setFilename(outname)
    form.slcImage = slcImg

    form.formslc()

    ####Populate frame metadata for SLC
    width = form.slcImage.getWidth()
    length = form.slcImage.getLength()
    prf = frame.PRF
    delr = frame.instrument.getRangePixelSize()

    ####Start creating an SLC frame to work with
    slcFrame = copy.deepcopy(frame)

    slcFrame.setStartingRange(form.startingRange)
    slcFrame.setFarRange(form.startingRange + (width - 1) * delr)

    tstart = form.slcSensingStart
    tmid = tstart + datetime.timedelta(seconds=0.5 * length / prf)
    tend = tstart + datetime.timedelta(seconds=(length - 1) / prf)

    slcFrame.sensingStart = tstart
    slcFrame.sensingMid = tmid
    slcFrame.sensingStop = tend

    form.slcImage.setAccessMode('READ')
    form.slcImage.setXmin(0)
    form.slcImage.setXmax(width)
    slcFrame.setImage(form.slcImage)

    slcFrame.setNumberOfSamples(width)
    slcFrame.setNumberOfLines(length)

    #####Adjust the doppler polynomial
    dop = frame._dopplerVsPixel[::-1]
    xx = np.linspace(0, (width - 1), num=len(dop) + 1)
    x = (slcFrame.startingRange - frame.startingRange) / delr + xx
    v = np.polyval(dop, x)
    p = np.polyfit(xx, v, len(dop) - 1)[::-1]
    slcFrame._dopplerVsPixel = list(p)
    slcFrame._dopplerVsPixel[0] += amb * prf

    return slcFrame