{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from snapista import Graph\n", "from snapista import Operator\n", "from snapista import TargetBand\n", "from snapista import TargetBandDescriptors" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "r = Operator(\"Read\", file='/data/S2B_MSIL2A_20210608T112119_N0300_R037_T29SMC_20210608T131325.SAFE/MTD_MSIL2A.xml')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Operator('Read', file='None', formatName='None', bandNames='None', maskNames='None', pixelRegion='None', geometryRegion='None', copyMetadata='true')" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Operator" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Instantiate a SNAP operator by providing its name:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Operator('Calibration', sourceBandNames='None', auxFile='Latest Auxiliary File', externalAuxFile='None', outputImageInComplex='false', outputImageScaleInDb='false', createGammaBand='false', createBetaBand='false', selectedPolarisations='None', outputSigmaBand='true', outputGammaBand='false', outputBetaBand='false')" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "calibration = Operator('Calibration')\n", "\n", "calibration" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get the SNAP Operator description:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Operator name: Calibration\n", "\n", "Description: Calibration of products\n", "Authors: Jun Lu, Luis Veci\n", "\n", "org.esa.s1tbx.calibration.gpf.CalibrationOp\n", "Version: 1.0\n", "\n", "Parameters:\n", "\n", "\tsourceBandNames: The list of source bands.\n", "\t\tDefault Value: None\n", "\n", "\t\tPossible values: []\n", "\n", "\tauxFile: The auxiliary file\n", "\t\tDefault Value: Latest Auxiliary File\n", "\n", "\t\tPossible values: ['Latest Auxiliary File', 'Product Auxiliary File', 'External Auxiliary File']\n", "\n", "\texternalAuxFile: The antenna elevation pattern gain auxiliary data file.\n", "\t\tDefault Value: None\n", "\n", "\t\tPossible values: []\n", "\n", "\toutputImageInComplex: Output image in complex\n", "\t\tDefault Value: false\n", "\n", "\t\tPossible values: []\n", "\n", "\toutputImageScaleInDb: Output image scale\n", "\t\tDefault Value: false\n", "\n", "\t\tPossible values: []\n", "\n", "\tcreateGammaBand: Create gamma0 virtual band\n", "\t\tDefault Value: false\n", "\n", "\t\tPossible values: []\n", "\n", "\tcreateBetaBand: Create beta0 virtual band\n", "\t\tDefault Value: false\n", "\n", "\t\tPossible values: []\n", "\n", "\tselectedPolarisations: The list of polarisations\n", "\t\tDefault Value: None\n", "\n", "\t\tPossible values: []\n", "\n", "\toutputSigmaBand: Output sigma0 band\n", "\t\tDefault Value: true\n", "\n", "\t\tPossible values: []\n", "\n", "\toutputGammaBand: Output gamma0 band\n", "\t\tDefault Value: false\n", "\n", "\t\tPossible values: []\n", "\n", "\toutputBetaBand: Output beta0 band\n", "\t\tDefault Value: false\n", "\n", "\t\tPossible values: []\n", "\n" ] } ], "source": [ "calibration.describe()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Instantiate a SNAP operator by providing its name and update a parameter value" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "calibration = Operator('Calibration')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['__class__',\n", " '__delattr__',\n", " '__dict__',\n", " '__dir__',\n", " '__doc__',\n", " '__eq__',\n", " '__format__',\n", " '__ge__',\n", " '__getattribute__',\n", " '__gt__',\n", " '__hash__',\n", " '__init__',\n", " '__init_subclass__',\n", " '__le__',\n", " '__lt__',\n", " '__module__',\n", " '__ne__',\n", " '__new__',\n", " '__reduce__',\n", " '__reduce_ex__',\n", " '__repr__',\n", " '__setattr__',\n", " '__sizeof__',\n", " '__str__',\n", " '__subclasshook__',\n", " '__weakref__',\n", " '_get_formats',\n", " '_params',\n", " 'auxFile',\n", " 'createBetaBand',\n", " 'createGammaBand',\n", " 'describe',\n", " 'externalAuxFile',\n", " 'operator',\n", " 'outputBetaBand',\n", " 'outputGammaBand',\n", " 'outputImageInComplex',\n", " 'outputImageScaleInDb',\n", " 'outputSigmaBand',\n", " 'selectedPolarisations',\n", " 'sourceBandNames',\n", " 'to_dict']" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dir(calibration)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Operator('Calibration', sourceBandNames='None', auxFile='Latest Auxiliary File', externalAuxFile='None', outputImageInComplex='false', outputImageScaleInDb='false', createGammaBand='false', createBetaBand='true', selectedPolarisations='None', outputSigmaBand='true', outputGammaBand='false', outputBetaBand='false')" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "calibration.createBetaBand = 'true'\n", "\n", "calibration" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Instantiate a SNAP operator by providing its name and setting the values in the constructor " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Operator('Calibration', sourceBandNames='None', auxFile='Latest Auxiliary File', externalAuxFile='None', outputImageInComplex='false', outputImageScaleInDb='false', createGammaBand='true', createBetaBand='true', selectedPolarisations='None', outputSigmaBand='true', outputGammaBand='false', outputBetaBand='false')" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "calibration = Operator('Calibration', \n", " createBetaBand='true', \n", " createGammaBand='true')\n", "\n", "calibration" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Calibration:\n", "\tsourceBandNames='None'\n", "\tauxFile='Latest Auxiliary File'\n", "\texternalAuxFile='None'\n", "\toutputImageInComplex='false'\n", "\toutputImageScaleInDb='false'\n", "\tcreateGammaBand='true'\n", "\tcreateBetaBand='true'\n", "\tselectedPolarisations='None'\n", "\toutputSigmaBand='true'\n", "\toutputGammaBand='false'\n", "\toutputBetaBand='false'\n" ] } ], "source": [ "print(calibration)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Graph" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a graph:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Graph(wdir='.')" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g = Graph()\n", "\n", "g" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "gpt binary: /srv/conda/envs/notebook/snap/bin/gpt\n", "working dir: .\n", "\n", "\n", " 1.0\n", "\n", "\n" ] } ], "source": [ "print(g)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add two nodes:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "g.add_node(operator=Operator('Read'), \n", " node_id='read_1')\n", "\n", "calibration = Operator('Calibration')\n", "\n", "calibration.createBetaBand = 'false'\n", "\n", "g.add_node(operator=calibration, \n", " node_id='calibration', \n", " source='read_1')" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " 1.0\n", " \n", " Read\n", " \n", " \n", " \n", " true\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " Calibration\n", " \n", " \n", " \n", " \n", " Latest Auxiliary File\n", " false\n", " false\n", " \n", " false\n", " false\n", " false\n", " false\n", " true\n", " \n", " \n", " \n", " \n", "\n", "\n" ] } ], "source": [ "g.view()" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "gpt binary: /srv/conda/envs/notebook/snap/bin/gpt\n", "working dir: .\n", "\n", "\n", " 1.0\n", " \n", " Read\n", " \n", " \n", " \n", " true\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " Calibration\n", " \n", " \n", " \n", " \n", " Latest Auxiliary File\n", " false\n", " false\n", " \n", " false\n", " false\n", " false\n", " false\n", " true\n", " \n", " \n", " \n", " \n", "\n", "\n" ] } ], "source": [ "print(g)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get a list of the SNAP operators" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['CloudProb',\n", " 'LandWaterMask',\n", " 'Resample',\n", " 'S2Resampling',\n", " 'ReplaceMetadata',\n", " 'Polarimetric-Decomposition',\n", " 'Meris.LandClassification',\n", " 'Terrain-Flattening',\n", " 'TsaviOp',\n", " 'McariOp',\n", " 'Three-passDInSAR',\n", " 'OlciO2aHarmonisation',\n", " 'Polarimetric-Speckle-Filter',\n", " 'SnaphuImport',\n", " 'Meris.Mod08Aerosol',\n", " 'CP-Simulation',\n", " 'Maximum-Likelihood-Classifier',\n", " 'ForestCoverChangeOp',\n", " 'BandMaths',\n", " 'Meris.AerosolMerger',\n", " 'AATSR.Ungrid',\n", " 'FUB.Water',\n", " 'SmacOp',\n", " 'Image-Filter',\n", " 'Terrain-Correction',\n", " 'AdaptiveThresholding',\n", " 'LinearToFromdB',\n", " 'PixEx',\n", " 'RangeFilter',\n", " 'Back-Geocoding',\n", " 'c2rcc.olci',\n", " 'Meris.CloudShadow',\n", " 'SetNoDataValue',\n", " 'Polarimetric-Matrices',\n", " 'PhaseToHeight',\n", " 'TestPattern',\n", " 'TemporalPercentile',\n", " 'DeburstWSS',\n", " 'IEM-Multi-Angle-Inversion',\n", " 'Minimum-Distance-Classifier',\n", " 'PduStitching',\n", " 'Mosaic',\n", " 'DecisionTree',\n", " 'Meris.Brr',\n", " 'ReflectanceToRadianceOp',\n", " 'CiOp',\n", " 'Oil-Spill-Clustering',\n", " 'Stack-Split',\n", " 'ToolAdapterOp',\n", " 'PhaseToDisplacement',\n", " 'Random-Forest-Classifier',\n", " 'RemoteExecutionOp',\n", " 'BandMerge',\n", " 'PCA',\n", " 'c2rcc.meris',\n", " 'Wind-Field-Estimation',\n", " 'Read',\n", " 'KNN-Classifier',\n", " 'S2tbx-Reproject',\n", " 'SRGR',\n", " 'MtciOp',\n", " 'SAR-Mosaic',\n", " 'L3ToL1',\n", " 'Oil-Spill-Detection',\n", " 'ArviOp',\n", " 'Meris.SmileCorrection',\n", " 'SnaphuExport',\n", " 'Double-Difference-Interferogram',\n", " 'Mci.s2',\n", " 'Multi-size Mosaic',\n", " 'TndviOp',\n", " 'Remodulate',\n", " 'NdviOp',\n", " 'WriteRGB',\n", " 'FillAerosol',\n", " 'MultiMasterStackGenerator',\n", " 'Ndi45Op',\n", " 'StoredGraph',\n", " 'TOPSAR-Merge',\n", " 'GaborFilter',\n", " 'SM-Dielectric-Modeling',\n", " 'Convert-Datatype',\n", " 'BandsDifferenceOp',\n", " 'c2rcc.seawifs',\n", " 'IreciOp',\n", " 'Offset-Tracking',\n", " 'IpviOp',\n", " 'SimulateAmplitude',\n", " 'Warp',\n", " 'SmileCorrection.Olci',\n", " 'Azimuth-Shift-Estimation-ESD',\n", " 'OWTClassification',\n", " 'Object-Discrimination',\n", " 'TOPSAR-Split',\n", " 'MoreThenAnIntegerOp',\n", " 'Update-Geo-Reference',\n", " 'Flood-Detection',\n", " 'Polarimetric-Classification',\n", " 'Meris.CloudTopPressureOp',\n", " 'Demodulate',\n", " 'CreateStack',\n", " 'Reproject',\n", " 'Rad2Refl',\n", " 'Principle-Components',\n", " 'SliceAssembly',\n", " 'ALOS-Deskewing',\n", " 'Ellipsoid-Correction-RD',\n", " 'SubGraph',\n", " 'S2repOp',\n", " 'ThermalNoiseRemoval',\n", " 'Find-Image-Pair',\n", " 'Orientation-Angle-Correction',\n", " 'Enhanced-Spectral-Diversity',\n", " 'GemiOp',\n", " 'Msavi2Op',\n", " 'BiophysicalOp',\n", " 'TileWriter',\n", " 'Apply-Orbit-File',\n", " 'c2rcc.viirs',\n", " 'Calibration',\n", " 'Supervised-Wishart-Classification',\n", " 'Coherence',\n", " 'FuClassification',\n", " 'PassThrough',\n", " 'BandSelect',\n", " 'MphChl',\n", " 'Undersample',\n", " 'PviOp',\n", " 'Binning',\n", " 'AddLandCover',\n", " 'AzimuthFilter',\n", " 'MphChlMeris',\n", " 'RRToFRS',\n", " 'c2rcc',\n", " 'BandsExtractorOp',\n", " 'Multilook',\n", " 'PyOp',\n", " 'Ellipsoid-Correction-GG',\n", " 'IEM-Multi-Pol-Inversion',\n", " 'FlhMci',\n", " 'EAP-Phase-Correction',\n", " 'TopoPhaseRemoval',\n", " 'MphChlBasis',\n", " 'Forest-Area-Classification',\n", " 'SARSim-Terrain-Correction',\n", " 'Oversample',\n", " 'Subset',\n", " 'MsaviOp',\n", " 'Collocate',\n", " 'c2rcc.meris4',\n", " 'Change-Detection',\n", " 'RayleighCorrection',\n", " 'Polarimetric-Parameters',\n", " 'BiOp',\n", " 'GenericRegionMergingOp',\n", " 'RviOp',\n", " 'GndviOp',\n", " 'IntegerInterferogram',\n", " 'PhaseToElevation',\n", " 'DEM-Assisted-Coregistration',\n", " 'PpeFiltering',\n", " 'Write',\n", " 'PssraOp',\n", " 'KMeansClusterAnalysis',\n", " 'Meris.Sdr',\n", " 'Import-Vector',\n", " 'NdpiOp',\n", " 'SpectralAngleMapperOp',\n", " 'c2rcc.landsat8',\n", " 'ProductSet-Reader',\n", " 'Meris.GaseousCorrection',\n", " 'Multi-Temporal-Speckle-Filter',\n", " 'CoregistrationOp',\n", " 'Bi2Op',\n", " 'DviOp',\n", " 'c2rcc.landsat7',\n", " 'Stack-Averaging',\n", " 'Fill-DEM-Hole',\n", " 'CP-Stokes-Parameters',\n", " 'TileCache',\n", " 'NdtiOp',\n", " 'Speckle-Filter',\n", " 'StatisticsOp',\n", " 'RiOp',\n", " 'WdviOp',\n", " 'SAR-Simulation',\n", " 'EMClusterAnalysis',\n", " 'Speckle-Divergence',\n", " 'SaviOp',\n", " 'c2rcc.msi',\n", " 'BiophysicalLandsat8Op',\n", " 'IEM-Hybrid-Inversion',\n", " 'KDTree-KNN-Classifier',\n", " 'FillBand',\n", " 'Land-Sea-Mask',\n", " 'Data-Analysis',\n", " 'Interferogram',\n", " 'TOPSAR-Deburst',\n", " 'Arc.SST',\n", " 'Ndwi2Op',\n", " 'RemoveAntennaPattern',\n", " 'Merge',\n", " 'CP-Decomposition',\n", " 'Forest-Area-Detection',\n", " 'Aatsr.SST',\n", " 'Meris.CloudProbability',\n", " 'Land-Cover-Mask',\n", " 'Biophysical10mOp',\n", " 'MphChlOlci',\n", " 'Meris.N1Patcher',\n", " 'Meris.RayleighCorrection',\n", " 'Meris.GapLessSdr',\n", " 'ReipOp',\n", " 'GRD-Post',\n", " 'Meris.CombinedCloud',\n", " 'Meris.BlueBand',\n", " 'GLCM',\n", " 'GoldsteinPhaseFiltering',\n", " 'Terrain-Mask',\n", " 'AddElevation',\n", " 'Unmix',\n", " 'CrossResampling',\n", " 'GaseousAbsorption',\n", " 'Compute-Slope-Aspect',\n", " 'StampsExport',\n", " 'Cross-Correlation',\n", " 'Remove-GRD-Border-Noise',\n", " 'Flip',\n", " 'Meris.CorrectRadiometry',\n", " 'Cross-Channel-SNR-Correction',\n", " 'c2rcc.modis',\n", " 'Meris.CloudClassification',\n", " 'TOPSAR-DerampDemod',\n", " 'MndwiOp',\n", " 'NdwiOp']" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Graph.list_operators()" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SARSim-Terrain-Correction - Orthorectification with SAR simulation\n", "AzimuthFilter - Azimuth Filter\n", "TopoPhaseRemoval - Compute and subtract TOPO phase\n", "Ellipsoid-Correction-RD - Ellipsoid correction with RD method and average scene height\n", "Polarimetric-Classification - Perform Polarimetric classification of a given product\n", "GaborFilter - Extract Texture Features\n", "Terrain-Correction - RD method for orthorectification\n", "FillBand - None\n", "Meris.CloudProbability - None\n", "DeburstWSS - Debursts an ASAR WSS product\n", "IntegerInterferogram - Create integer interferogram\n", "Undersample - Undersample the datset\n", "OWTClassification - Performs an optical water type classification based on atmospherically corrected reflectances.\n", "Demodulate - Demodulation and deramping of SLC data\n", "RiOp - The Redness Index was developed to identify soil colour variations.\n", "Image-Filter - Common Image Processing Filters\n", "Back-Geocoding - Bursts co-registration using orbit and DEM\n", "Read - Reads a data product from a given file location.\n", "Meris.AerosolMerger - None\n", "Write - Writes a data product to a file.\n", "ReipOp - The red edge inflection point index\n", "GndviOp - Green Normalized Difference Vegetation Index\n", "Azimuth-Shift-Estimation-ESD - Estimate azimuth offset for the whole image\n", "NdviOp - The retrieves the Normalized Difference Vegetation Index (NDVI).\n", "TOPSAR-DerampDemod - Bursts co-registration using orbit and DEM\n", "TOPSAR-Deburst - Debursts a Sentinel-1 TOPSAR product\n", "GRD-Post - Applies GRD post-processing\n", "RviOp - Ratio Vegetation Index retrieves the Isovegetation lines converge at origin\n", "Change-Detection - Change Detection.\n", "Calibration - Calibration of products\n", "WdviOp - Weighted Difference Vegetation Index retrieves the Isovegetation lines parallel to soil line. Soil line has an arbitrary slope and passes through origin\n", "SM-Dielectric-Modeling - Performs SM inversion using dielectric model\n", "Meris.Sdr - None\n", "ThermalNoiseRemoval - Removes thermal noise from products\n", "SnaphuImport - Ingest SNAPHU results into InSAR product.\n", "PhaseToDisplacement - Phase To Displacement Conversion along LOS\n", "Meris.Mod08Aerosol - None\n", "Flood-Detection - Detect flooded area.\n", "Oil-Spill-Detection - Detect oil spill.\n", "Collocate - Collocates two products based on their geo-codings.\n", "Speckle-Divergence - Detect urban area.\n", "DviOp - Difference Vegetation Index retrieves the Isovegetation lines parallel to soil line\n", "SliceAssembly - Merges Sentinel-1 slice products\n", "ReplaceMetadata - Replace the metadata of the first product with that of the second\n", "MphChlMeris - Computes maximum peak height of chlorophyll for MERIS. Implements MERIS-specific parts.\n", "TileWriter - Writes a data product to a tiles.\n", "c2rcc.seawifs - Performs atmospheric correction and IOP retrieval on SeaWifs L1C data products.\n", "PhaseToHeight - Phase to Height conversion\n", "SRGR - Converts Slant Range to Ground Range\n", "PCA - Performs a Principal Component Analysis.\n", "ALOS-Deskewing - Deskewing ALOS product\n", "PixEx - Extracts pixels from given locations and source products.\n", "NdpiOp - The normalized differential pond index, combines the short-wave infrared band-I and the green band\n", "SaviOp - This retrieves the Soil-Adjusted Vegetation Index (SAVI).\n", "BandsExtractorOp - Creates a new product out of the source product containing only the indexes bands given\n", "TileCache - Experimental Operator which provides a dedicated cache for its source product.\n", "A guide on how this operator is used is provided at https://senbox.atlassian.net/wiki/x/VQCTLw.\n", "L3ToL1 - None\n", "Cross-Channel-SNR-Correction - Compute general polarimetric parameters\n", "SimulateAmplitude - Simulate amplitude based on DEM\n", "Supervised-Wishart-Classification - Perform supervised Wishart classification\n", "BandMaths - Create a product with one or more bands using mathematical expressions.\n", "BiophysicalLandsat8Op - The 'Biophysical Processor' operator retrieves LAI from atmospherically corrected Landsat8 products\n", "Data-Analysis - Computes statistics\n", "TOPSAR-Merge - Merge subswaths of a Sentinel-1 TOPSAR product\n", "BandSelect - Creates a new product with only selected bands\n", "MoreThenAnIntegerOp - just for testing\n", "TndviOp - Transformed Normalized Difference Vegetation Index retrieves the Isovegetation lines parallel to soil line\n", "StampsExport - Export data for StaMPS processing\n", "Multilook - Averages the power across a number of lines in both the azimuth and range directions\n", "c2rcc.meris - Performs atmospheric correction and IOP retrieval with uncertainties on MERIS L1b data products.\n", "TsaviOp - This retrieves the Transformed Soil Adjusted Vegetation Index (TSAVI).\n", "Terrain-Mask - Terrain Mask Generation\n", "Meris.LandClassification - MERIS L2 land/water reclassification.\n", "SmacOp - Applies the Simplified Method for Atmospheric Corrections of Envisat MERIS/(A)ATSR measurements.\n", "GenericRegionMergingOp - The 'Generic Region Merging' operator computes the distinct regions from a product\n", "PduStitching - Stitches multiple SLSTR L1B product dissemination units (PDUs) of the same orbit to a single product.\n", "RayleighCorrection - Performs radiometric corrections on OLCI, MERIS L1B and S2 MSI L1C data products.\n", "Meris.CloudShadow - None\n", "Binning - Performs spatial and temporal aggregation of pixel values into cells ('bins') of a planetary grid\n", "AddLandCover - Creates a land cover band\n", "MphChlBasis - Computes maximum peak height of chlorophyll. Basis class, contains sensor-independent parts.\n", "Mci.s2 - Computes maximum chlorophyll index (MCI) for Sentinel-2 MSI.\n", "SmileCorrection.Olci - Performs radiometric corrections on OLCI L1b data products.\n", "RemoveAntennaPattern - Remove Antenna Pattern\n", "Wind-Field-Estimation - Estimate wind speed and direction\n", "DEM-Assisted-Coregistration - Orbit and DEM based co-registration\n", "SAR-Simulation - Rigorous SAR Simulation\n", "Random-Forest-Classifier - Random Forest based classifier\n", "AdaptiveThresholding - Detect ships using Constant False Alarm Rate detector.\n", "Meris.RayleighCorrection - MERIS L2 rayleigh correction.\n", "PpeFiltering - Performs Prompt Particle Event (PPE) filtering on OLCI L1B\n", "Remove-GRD-Border-Noise - Mask no-value pixels for GRD product\n", "Import-Vector - Imports a shape file into a product\n", "MphChlOlci - Computes maximum peak height of chlorophyll for OLCI. Implements OLCI-specific parts.\n", "Enhanced-Spectral-Diversity - Estimate constant range and azimuth offsets for a stack of images\n", "Polarimetric-Parameters - Compute general polarimetric parameters\n", "GemiOp - This retrieves the Global Environmental Monitoring Index (GEMI).\n", "RRToFRS - None\n", "RangeFilter - Range Filter\n", "KNN-Classifier - K-Nearest Neighbour classifier\n", "Polarimetric-Matrices - Generates covariance or coherency matrix for given product\n", "Reproject - Reprojection of a source product to a target Coordinate Reference System.\n", "Meris.GaseousCorrection - MERIS L2 gaseous absorbtion correction.\n", "Object-Discrimination - Remove false alarms from the detected objects.\n", "Oversample - Oversample the datset\n", "CloudProb - Applies a clear sky conservative cloud detection algorithm.\n", "MtciOp - The Meris Terrestrial Chlorophyll Index, aims at estimating the Red Edge Position (REP).\n", "This is the maximum slant point in the red and near-infrared region of the vegetal spectral reflectance.\n", "It is useful for observing the chlorophyll contents, vegetation senescence, and stress for water and nutritional deficiencies, but it is less suitable for land classification\n", "Land-Sea-Mask - Creates a bitmask defining land vs ocean.\n", "FuClassification - Colour classification based on the discrete Forel-Ule scale.\n", "Find-Image-Pair - DB query to find matching image pair\n", "TemporalPercentile - Computes percentiles over a given time period.\n", "Rad2Refl - Provides conversion from radiances to reflectances or backwards.\n", "DecisionTree - Perform decision tree classification\n", "c2rcc.msi - Performs atmospheric correction and IOP retrieval with uncertainties on Sentinel-2 MSI L1C data products.\n", "Polarimetric-Decomposition - Perform Polarimetric decomposition of a given product\n", "CP-Stokes-Parameters - Generates compact polarimetric Stokes child parameters\n", "EAP-Phase-Correction - EAP Phase Correction\n", "Resample - Resampling of a multi-size source product to a single-size target product.\n", "Ellipsoid-Correction-GG - GG method for orthorectification\n", "c2rcc.meris4 - Performs atmospheric correction and IOP retrieval with uncertainties on MERIS L1b data products from the 4th reprocessing.\n", "TOPSAR-Split - Creates a new product with only the selected subswath\n", "Meris.CloudTopPressureOp - Computes cloud top pressure with FUB NN.\n", "NdtiOp - Normalized difference turbidity index, allowing for the measurement of water turbidity\n", "c2rcc - Performs atmospheric correction and IOP retrieval on OLCI, MSI, MERIS, MODIS or SeaWiFS L1 product.\n", "Principle-Components - Principle Component Analysis\n", "ProductSet-Reader - Adds a list of sources\n", "CreateStack - Collocates two or more products based on their geo-codings.\n", "FillAerosol - None\n", "StoredGraph - Encapsulates an stored graph into an operator.\n", "LinearToFromdB - Converts bands to/from dB\n", "Meris.CombinedCloud - None\n", "CoregistrationOp - Coregisters two rasters, not considering their location\n", "IEM-Multi-Pol-Inversion - Performs IEM inversion using Multi-polarization approach\n", "IEM-Hybrid-Inversion - Performs IEM inversion using Hybrid approach\n", "McariOp - Modified Chlorophyll Absorption Ratio Index, developed to be responsive to chlorophyll variation\n", "NdwiOp - The Normalized Difference Water Index was developed for the extraction of water features\n", "ToolAdapterOp - Tool Adapter Operator\n", "Meris.SmileCorrection - None\n", "c2rcc.landsat7 - Performs atmospheric correction and IOP retrieval with uncertainties on Landsat-7 L1 data products.\n", "PviOp - Perpendicular Vegetation Index retrieves the Isovegetation lines parallel to soil line. Soil line has an arbitrary slope and passes through origin\n", "LandWaterMask - Operator creating a target product with a single band containing a land/water-mask.\n", "FlhMci - Computes fluorescence line height (FLH) or maximum chlorophyll index (MCI).\n", "GaseousAbsorption - Correct the influence of atmospheric gas absorption for those OLCI channels.\n", "CrossResampling - Estimate Resampling Polynomial using SAR Image Geometry, and Resample Input Images\n", "Update-Geo-Reference - Update Geo Reference\n", "Mosaic - Creates a mosaic out of a set of source products.\n", "Three-passDInSAR - Differential Interferometry\n", "GLCM - Extract Texture Features\n", "S2Resampling - Specific S2 resample algorithm\n", "Meris.N1Patcher - Copies an existing N1 file and replaces the data for the radiance bands\n", "IreciOp - Inverted red-edge chlorophyll index\n", "OlciO2aHarmonisation - Performs O2A band harmonisation on OLCI L1b product.\n", "SAR-Mosaic - Mosaics two or more products based on their geo-codings.\n", "CiOp - Colour Index was developed to differentiate soils in the field.\n", "In most cases the CI gives complementary information with the BI and the NDVI.\n", " Used for diachronic analyses, they help for a better understanding of the evolution of soil surfaces.\n", "Ndwi2Op - The Normalized Difference Water Index, allowing for the measurement of surface water extent\n", "Terrain-Flattening - Terrain Flattening\n", "SpectralAngleMapperOp - Classifies a product using the spectral angle mapper algorithm\n", "Merge - Allows merging of several source products by using specified 'master' as reference product.\n", "PssraOp - Pigment Specific Simple Ratio, chlorophyll index\n", "Meris.Brr - Performs the Rayleigh correction on a MERIS L1b product.\n", "Flip - flips a product horizontal/vertical\n", "BiophysicalOp - The 'Biophysical Processor' operator retrieves LAI from atmospherically corrected Sentinel-2 products\n", "Meris.CloudClassification - MERIS L2 cloud classification.\n", "Msavi2Op - This retrieves the second Modified Soil Adjusted Vegetation Index (MSAVI2).\n", "PyOp - Uses Python code to process data products\n", "Convert-Datatype - Convert product data type\n", "Stack-Split - Writes all bands to files.\n", "MphChl - This operator computes maximum peak height of chlorophyll (MPH/CHL).\n", "Polarimetric-Speckle-Filter - Polarimetric Speckle Reduction\n", "KMeansClusterAnalysis - Performs a K-Means cluster analysis.\n", "Coherence - Estimate coherence from stack of coregistered images\n", "Arc.SST - Computes sea surface temperature (SST) from (A)ATSR and SLSTR products.\n", "Subset - Create a spatial and/or spectral subset of a data product.\n", "MultiMasterStackGenerator - Generates a set of master-slave pairs from a coregistered stack for use in SBAS processing\n", "GoldsteinPhaseFiltering - Phase Filtering\n", "Interferogram - Compute interferograms from stack of coregistered S-1 images\n", "RemoteExecutionOp - The Remote Execution Processor executes on the remote machines a slave graph and then on the host machine it executes a master graph using the products created by the remote machines.\n", "c2rcc.olci - Performs atmospheric correction and IOP retrieval with uncertainties on SENTINEL-3 OLCI L1B data products.\n", "Fill-DEM-Hole - Fill holes in given DEM product file.\n", "Apply-Orbit-File - Apply orbit file\n", "Offset-Tracking - Create velocity vectors from offset tracking\n", "FUB.Water - FUB/WeW WATER Processor to retrieve case II water properties and atmospheric properties\n", "S2repOp - Sentinel-2 red-edge position index\n", "Cross-Correlation - Automatic Selection of Ground Control Points\n", "EMClusterAnalysis - Performs an expectation-maximization (EM) cluster analysis.\n", "Double-Difference-Interferogram - Compute double difference interferogram\n", "Forest-Area-Detection - Detect forest area.\n", "Minimum-Distance-Classifier - Minimum Distance classifier\n", "c2rcc.landsat8 - Performs atmospheric correction and IOP retrieval with uncertainties on Landsat-8 L1 data products.\n", "AATSR.Ungrid - Ungrids (A)ATSR L1B products and extracts geolocation and pixel field of view data.\n", "CP-Simulation - Simulation of Compact Pol data from Quad Pol data\n", "S2tbx-Reproject - Reprojection of a source product to a target Coordinate Reference System.\n", "TestPattern - For testing only\n", "SetNoDataValue - Set NoDataValueUsed flag and NoDataValue for all bands\n", "PhaseToElevation - DEM Generation\n", "Land-Cover-Mask - Perform decision tree classification\n", "Meris.CorrectRadiometry - Performs radiometric corrections on MERIS L1b data products.\n", "AddElevation - Creates a DEM band\n", "Remodulate - Remodulation and reramping of SLC data\n", "Meris.GapLessSdr - None\n", "MndwiOp - Modified Normalized Difference Water Index, allowing for the measurement of surface water extent\n", "Multi-size Mosaic - Creates a multi-size mosaic out of a set of source products.\n", "Multi-Temporal-Speckle-Filter - Speckle Reduction using Multitemporal Filtering\n", "CP-Decomposition - Perform Compact Polarimetric decomposition of a given product\n", "Warp - Create Warp Function And Get Co-registrated Images\n", "PassThrough - Sets target product to source product.\n", "c2rcc.viirs - Performs atmospheric correction and IOP retrieval on Viirs L1C data products.\n", "Ndi45Op - Normalized Difference Index using bands 4 and 5\n", "BandsDifferenceOp - None\n", "Orientation-Angle-Correction - Perform polarization orientation angle correction for given coherency matrix\n", "Speckle-Filter - Speckle Reduction\n", "WriteRGB - Creates an RGB image from three source bands.\n", "MsaviOp - This retrieves the Modified Soil Adjusted Vegetation Index (MSAVI).\n", "Meris.BlueBand - None\n", "ArviOp - Atmospherically Resistant Vegetation Index belongs to a family of indices with built-in atmospheric corrections.\n", "SnaphuExport - Export data and prepare conf file for SNAPHU processing\n", "StatisticsOp - Computes statistics for an arbitrary number of source products.\n", "SubGraph - Encapsulates a graph within a graph.\n", "Oil-Spill-Clustering - Remove small clusters from detected area.\n", "ReflectanceToRadianceOp - The 'Reflectance To Radiance Processor' operator retrieves the radiance from reflectance using Sentinel-2 products\n", "IEM-Multi-Angle-Inversion - Performs IEM inversion using Multi-angle approach\n", "Forest-Area-Classification - Detect forest area\n", "Stack-Averaging - Averaging multi-temporal images\n", "Aatsr.SST - Computes sea surface temperature (SST) from (A)ATSR products.\n", "Bi2Op - The Brightness index represents the average of the brightness of a satellite image.\n", "This index is sensitive to the brightness of soils which is highly correlated with the humidity and the presence of salts in surface\n", "KDTree-KNN-Classifier - KDTree KNN classifier\n", "IpviOp - Infrared Percentage Vegetation Index retrieves the Isovegetation lines converge at origin\n", "BiOp - The Brightness index represents the average of the brightness of a satellite image.\n", "Maximum-Likelihood-Classifier - Maximum Likelihood classifier\n", "Unmix - Performs a linear spectral unmixing.\n", "ForestCoverChangeOp - Creates forest change masks out of two source products\n", "c2rcc.modis - Performs atmospheric correction and IOP retrieval on MODIS L1C_LAC data products.\n", "Compute-Slope-Aspect - Compute Slope and Aspect from DEM\n", "Biophysical10mOp - The 'Biophysical Processor' operator retrieves LAI from atmospherically corrected Sentinel-2 products\n", "BandMerge - Allows copying raster data from any number of source products to a specified 'master' product.\n" ] } ], "source": [ "g.describe_operators()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a linear graph" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Adding Operator Read to graph\n", "Adding Operator Resample to graph\n", "Adding Operator Reproject to graph\n", "Adding Operator Subset to graph\n", "Adding Operator AddLandCover to graph\n", "Adding Operator Write to graph\n" ] } ], "source": [ "g = Graph() \n", "\n", "read = Operator('Read')\n", "\n", "read.formatName = 'SENTINEL-1'\n", "read.file = 'some1'\n", "\n", "\n", "operators = [read,\n", " 'Resample',\n", " 'Reproject',\n", " 'Subset',\n", " 'AddLandCover',\n", " 'Write']\n", "\n", "for index, operator in enumerate(operators):\n", " \n", " print('Adding Operator {} to graph'.format(operator.operator if isinstance(operator, Operator) else operator))\n", " if index == 0: \n", " source_node_id = ''\n", "\n", " else:\n", " source_node_id = operators[index - 1].operator if isinstance(operators[index - 1], Operator) else operators[index - 1]\n", " \n", " \n", " g.add_node(operator if isinstance(operator, Operator) else Operator(operator),\n", " operator.operator if isinstance(operator, Operator) else operator,\n", " source_node_id)\n", " " ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " 1.0\n", " \n", " Read\n", " \n", " \n", " \n", " \n", " \n", " true\n", " some1\n", " SENTINEL-1\n", " \n", " \n", " \n", " \n", " \n", " \n", " Resample\n", " \n", " \n", " \n", " \n", " \n", " First\n", " First\n", " \n", " true\n", " \n", " \n", " \n", " \n", " Nearest\n", " \n", " \n", " \n", " Reproject\n", " \n", " \n", " \n", " \n", " false\n", " \n", " \n", " \n", " \n", " true\n", " \n", " \n", " 0\n", " false\n", " \n", " \n", " \n", " \n", " Nearest\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " Subset\n", " \n", " \n", " \n", " \n", " \n", " false\n", " false\n", " \n", " \n", " \n", " 1\n", " 1\n", " \n", " \n", " \n", " \n", " AddLandCover\n", " \n", " \n", " \n", " \n", " \n", " AAFC Canada Sand Pct\n", " NEAREST_NEIGHBOUR\n", " \n", " \n", " \n", " Write\n", " \n", " \n", " \n", " \n", " false\n", " true\n", " \n", " BEAM-DIMAP\n", " false\n", " \n", " \n", "\n", "\n" ] } ], "source": [ "g.view()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#g.run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## BandMaths" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "band_maths = Operator('BandMaths')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Operator name: BandMaths\n", "\n", "Description: Create a product with one or more bands using mathematical expressions.\n", "Authors: Marco Zuehlke, Norman Fomferra, Marco Peters\n", "\n", "org.esa.snap.core.gpf.common.BandMathsOp\n", "Version: 1.1\n", "\n", "Parameters:\n", "\n", "\ttargetBandDescriptors: List of descriptors defining the target bands.\n", "\t\tDefault Value: None\n", "\n", "\t\tPossible values: []\n", "\n", "\tvariables: List of variables which can be used within the expressions.\n", "\t\tDefault Value: None\n", "\n", "\t\tPossible values: []\n", "\n" ] } ], "source": [ "band_maths.describe()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " active_fire_detected\n", " float32\n", " S9_BT_in < 265 ? 0 : F1_BT_in > 315 and (F1_BT_in - F2_BT_in) > 15 ? 1 : 0\n", " \n", " \n", " NaN\n", " " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "active_fire_band = TargetBand(name='active_fire_detected',\n", " expression='S9_BT_in < 265 ? 0 : F1_BT_in > 315 and (F1_BT_in - F2_BT_in) > 15 ? 1 : 0')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "TargetBand(name='active_fire_detected', expression='S9_BT_in < 265 ? 0 : F1_BT_in > 315 and (F1_BT_in - F2_BT_in) > 15 ? 1 : 0', band_type='float32', description=None, unit=None, no_data_value='NaN')" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "active_fire_band" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "band_maths.targetBandDescriptors = TargetBandDescriptors([active_fire_band])" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "g = Graph()\n", "\n", "g.add_node(operator=Operator('Read'), \n", " node_id='read_1')" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "g.add_node(operator=band_maths, \n", " node_id='band_maths', \n", " source='read_1')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " 1.0\n", " \n", " Read\n", " \n", " \n", " \n", " true\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " BandMaths\n", " \n", " \n", " \n", " \n", " \n", " \n", " active_fire_detected\n", " S9_BT_in &lt; 265 ? 0 : F1_BT_in &gt; 315 and (F1_BT_in - F2_BT_in) &gt; 15 ? 1 : 0\n", " float32\n", " \n", " \n", " NaN\n", " \n", " \n", " \n", " \n", " \n", "\n", "\n" ] } ], "source": [ "g.view()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Binning" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", "\n", "from snapista.binning import aggregators\n", "from snapista.binning import BinningVariable, BinningOutputBands, BinningBand, Aggregators\n", "from snapista import Graph\n", "from snapista import Operator\n", "import lxml.etree as etree\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "ag = aggregators.AggregatorAvg(var_name='pippo', target_name=\"target_name\", output_counts='true')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'type': 'AVG',\n", " 'var_name': 'pippo',\n", " 'target_name': 'target_name',\n", " 'weight_coeff': 0.0,\n", " 'description': None,\n", " 'output_counts': 'true',\n", " 'output_sums': 'true'}" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ag.to_dict()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "bv = BinningVariable(name='pippo', expression='aa', valid_expression='aa')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "BinningVariable(name='pippo', expression='aa', valid_expression='aa')" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bv" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bv.to_xml()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "b'pippoaaaa'" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "etree.tostring(bv.to_xml())" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "bb = BinningBand(index=\"0\", name='aa', min_value=0, max_value=100)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "ob = BinningOutputBands([bb])" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "b'0aa0100'" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "etree.tostring(ob.to_xml())" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[BinningVariable(name='pippo', expression='aa', valid_expression='aa')]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[bv]" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "binning = Operator('Binning')" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Operator('Binning', sourceProductPaths='None', sourceProductFormat='None', sourceGraphPaths='None', region='None', startDateTime='None', periodDuration='None', timeFilterMethod='NONE', minDataHour='None', numRows='2160', superSampling='1', maxDistanceOnEarth='-1', maskExpr='None', variableConfigs='None', aggregatorConfigs='None', postProcessorConfig='None', outputType='Product', outputFile='None', outputFormat='BEAM-DIMAP', bandConfigurations='None', productCustomizerConfig='None', outputBinnedData='false', outputTargetProduct='true', metadataPropertiesFile='./metadata.properties', metadataTemplateDir='.', metadataAggregatorName='NAME', planetaryGridClass='org.esa.snap.binning.support.SEAGrid')" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "binning" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Operator('Binning', sourceProductPaths='None', sourceProductFormat='None', sourceGraphPaths='None', region='None', startDateTime='None', periodDuration='None', timeFilterMethod='NONE', minDataHour='None', numRows='2160', superSampling='1', maxDistanceOnEarth='-1', maskExpr='None', variableConfigs='None', aggregatorConfigs='', postProcessorConfig='None', outputType='Product', outputFile='None', outputFormat='BEAM-DIMAP', bandConfigurations='', productCustomizerConfig='None', outputBinnedData='false', outputTargetProduct='true', metadataPropertiesFile='./metadata.properties', metadataTemplateDir='.', metadataAggregatorName='NAME', planetaryGridClass='org.esa.snap.binning.support.SEAGrid')" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "binning.aggregatorConfigs = Aggregators([ag])\n", "binning.bandConfigurations = BinningOutputBands([bb])\n", "binning" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "import os\n", "os.environ['PATH'] = '/srv/conda/envs/env_snap/snap/bin:' + os.environ['PATH']" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "aggregatorConfigs\n", "here 2\n", "maskExpr\n", "maxDistanceOnEarth\n", "metadataAggregatorName\n", "metadataPropertiesFile\n", "metadataTemplateDir\n", "minDataHour\n", "numRows\n", "outputBinnedData\n", "outputFile\n", "outputFormat\n", "outputTargetProduct\n", "outputType\n", "periodDuration\n", "planetaryGridClass\n", "postProcessorConfig\n", "productCustomizerConfig\n", "region\n", "sourceGraphPaths\n", "sourceProductFormat\n", "sourceProductPaths\n", "startDateTime\n", "superSampling\n", "timeFilterMethod\n", "variableConfigs\n" ] } ], "source": [ "g = Graph()\n", "\n", "g.add_node(operator=binning, \n", " node_id='binning_1')" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " 1.0\n", " \n", " Binning\n", " \n", " \n", " \n", " \n", " AVG\n", " pippo\n", " target_name\n", " 0.0\n", " None\n", " true\n", " true\n", " \n", " \n", " \n", " -1\n", " NAME\n", " ./metadata.properties\n", " .\n", " \n", " 2160\n", " false\n", " \n", " BEAM-DIMAP\n", " true\n", " Product\n", " \n", " org.esa.snap.binning.support.SEAGrid\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1\n", " NONE\n", " \n", " \n", " \n", "\n", "\n" ] } ], "source": [ "g.view()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", "\n", "from snapista.binning import aggregators\n", "from snapista.binning import BinningVariable, BinningOutputBands, BinningBand, Aggregators, BinningVariables\n", "from snapista import Graph\n", "from snapista import Operator\n", "import lxml.etree as etree\n", "import os\n", "\n", "os.environ['PATH'] = '/srv/conda/envs/env_snap/snap/bin:' + os.environ['PATH']\n", "\n", "ag = aggregators.AggregatorAvg(var_name='pippo', target_name=\"target_name\", output_counts='true')\n", "bv = BinningVariable(name='pippo', expression='aa', valid_expression='aa')\n", "bb = BinningBand(index=\"0\", name='aa', min_value=0, max_value=100)\n", "\n", "binning = Operator('Binning')\n", "\n", "binning.aggregatorConfigs = Aggregators([ag])\n", "binning.bandConfigurations = BinningOutputBands([bb])\n", "binning.variableConfigs = BinningVariables([bv])\n", "g = Graph()\n", "\n", "g.add_node(operator=binning, \n", " node_id='binning_1')" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " 1.0\n", " \n", " Binning\n", " \n", " \n", " \n", " \n", " AVG\n", " pippo\n", " target_name\n", " 0.0\n", " None\n", " true\n", " true\n", " \n", " \n", " \n", " \n", " 0\n", " aa\n", " 0\n", " 100\n", " \n", " \n", " \n", " -1\n", " NAME\n", " ./metadata.properties\n", " .\n", " \n", " 2160\n", " false\n", " \n", " BEAM-DIMAP\n", " true\n", " Product\n", " \n", " org.esa.snap.binning.support.SEAGrid\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1\n", " NONE\n", " \n", " \n", " pippo\n", " aa\n", " aa\n", " \n", " \n", " \n", " \n", "\n", "\n" ] } ], "source": [ "g.view()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.4" } }, "nbformat": 4, "nbformat_minor": 4 }