def createPath(self,coords,js_callback,err_callback): if coords: region = ScanArea.ScanRegion.from2DLatLonArray(coords,self._home, names = self._names) elif self._fname: region = ScanArea.ScanRegion.fromFile(self._fname,self._home) else: return region.setVehicle(self._vehicle) region.setAltitude(self._alt) region.setBearing(self._bearing) region.setSidelap(self._sidelap) region.setOvershoot(self._overshoot) region.setFindScanLineBounds(True) scanner = self._spectrometer or Spectrometer.HeadwallNanoHyperspec() scanner.setFramePeriod(self._scan_pd) px_size = scanner.pixelSizeAt(self._alt) region.setSpectrometer(scanner) try: region.findScanLines() coords = region.flattenCoords() bounds= region.boundBox scanlines=region.scanLineBoundBoxes dist = "%.2f"%(region.totalScanLength/1000) speed = "%.2f"%region.scanVelocity self._region = region js_callback.Call(coords,bounds,dist,speed,px_size,scanlines) except ScanArea.ScanLineDensityError: err_callback.Call()
def setSpectrometer(self,val,js_callback=None): try: self._spectrometer = Spectrometer.spectrometerByName(val)() except KeyError: #got an unknown spectrometer name, silently pass return if(js_callback): js_callback.Call(self._spectrometer.fieldOfView, self._spectrometer.crossFieldOfView, self._spectrometer.pixels)
def fromProjectShapeFile(Cls,shp_fname,home=None): coords = SHPParse.findPolyCoords(shp_fname) meta = SHPParse.findMeta(shp_fname) print(meta['inst'][0]) if 'sidelap' in meta: meta['sidelap'] = [s/100. for s in meta['sidelap']] try: spectrometer = Spectrometer.spectrometerByName(meta['inst'][0])() except: args= [meta[k][0]for k in ('fov','ifov','pixels','inst')] spectrometer = Spectrometer.Spectrometer(*args) #kwargs = {k:meta[k][0]for k in ('vehicle','alt','bearing','approach')} ''' kwargs['overshoot'] = kwargs.pop('approach') home = home or coords[0][0] region = Cls(home,**kwargs) names = meta['name'] for perimeter,name in zip(coords,names): region.addScanArea(ScanArea(home,perimeter,name = name )) region.setSpectrometer(spectrometer) ''' return spectrometer,coords,meta
def setCustomSpectrometer(self,fov,ifov,px): fov = float(fov) ifov = float(ifov) px = int(px) self._spectrometer = Spectrometer.Spectrometer(fov,ifov,px,'Custom')
ext = os.path.splitext(fname)[1].lower() for key in FILE_FUNC_TREE: if ext in key: dtype=FILE_FUNC_TREE[key]['type'](fname) return FILE_FUNC_TREE[key][dtype](fname,home,**kwargs) raise IOError("Unable to parse file {} into ScanRegion".format(fname)) if __name__ == '__main__': import sys region = ScanRegion.fromFile(sys.argv[1]) if len(sys.argv) > 3: region.setAltitude(int(sys.argv[3])) else: region.setAltitude(60) if len(sys.argv) > 4: region.setBearing(int(sys.argv[4])) else: region.setBearing(45) if len(sys.argv) > 5: region.setSidelap(float(sys.argv[5])) region.setFindScanLineBounds(True) scanner = Spectrometer.HeadwallNanoHyperspec() scanner.setFramePeriod(0.005) region.setSpectrometer(scanner) region.setOvershoot(30) region.setVehicle('fullscale') region.findScanLines() region.toGPX(sys.argv[2])