Commit 199ee425 authored by Lozac'h Loic's avatar Lozac'h Loic

hop

parent 9dfb8b01
......@@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
......@@ -23,5 +28,6 @@
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
......@@ -5,7 +5,7 @@
import subprocess, os
import argparse
import argparse, shutil
def search_files(directory='.', resolution='NDVI', extension='tif', fictype='f'):
images=[]
......@@ -40,47 +40,58 @@ if __name__ == "__main__":
# Make parser object
parser = argparse.ArgumentParser(description=
"""
Compute cloud-masked NDVI from Sentinel2 L2A (Sen2Cor) dimap using current directory.
Batch calibration and orthorectification of Sentinel-1 images with ESA SNAP
""")
parser.add_argument('-s1dir', action='store', required=True, help='Directory containing Sentinel1 zip file')
parser.add_argument('-s1dir', action='store', required=True, help='Directory containing Sentinel-1 zip file')
parser.add_argument('-graph', action='store', required=True, help='ESA SNAP xml graph file')
#parser.add_argument('-auxdir', action='store', required=True, help='Directory for ESA SNAP auxiliary files (DEM)')
parser.add_argument('-outdir', action='store', required=True, help='Output directory for Sentinel-1 calibrated files')
parser.add_argument('--zipfile', dest='zipfile', action='store_true', help='Process .zip file or .safe directory (default zip)')
parser.add_argument('--safefile', dest='zipfile', action='store_false')
parser.set_defaults(zipfile=True)
parser.add_argument('--docker', dest='docker', action='store_true', help='Use Docker ESA Snap image fro processing, default true')
parser.add_argument('--no-docker', dest='docker', action='store_false')
parser.set_defaults(docker=True)
# parser.add_argument('--docker', dest='docker', action='store_true', help='Use Docker ESA Snap image for processing, default true')
# parser.add_argument('--no-docker', dest='docker', action='store_false')
# parser.set_defaults(docker=True)
args=parser.parse_args()
graphfile = "/mnt/GEOSUD_WA/SoilMoisture/_PROD/lib/sentinel1_Cal_TC.xml"
basedata = "/mnt/GEOSUD_WA/SoilMoisture/_PROD"
optvoldata = "-v "+basedata+":"+basedata
optvoluser = "-v "+basedata+"/lib/.snap:/home/lozach/.snap"
if not os.path.exists(graphfile):
print("Graphfile missing!")
exit
graphfile = args.graph #"/mnt/GEOSUD_WA/SoilMoisture/_PROD/lib/sentinel1_Cal_TC.xml"
#basedata = args.auxdir #"/mnt/GEOSUD_WA/SoilMoisture/_PROD"
optvoldata = "-v "+os.path.abspath(args.s1dir)+":"+os.path.abspath(args.s1dir)
#optvoluser = "-v "+args.auxdir+":/home/lozach/.snap"
my_env = os.environ.copy()
s1dir=[]
if args.zipfile:
s1dir=search_files(args.s1dir, 'S1', 'zip', 'f')
lenext=-3
else:
s1dir=search_files(args.s1dir, 'S1', 'safe', 'd')
lenext=-4
if not os.path.exists(args.outdir):
os.mkdir(args.outdir)
# shutil.copy(args.graph, args.outdir)
# graphfile = os.path.join(args.outdir, os.path.basename(args.graph))
print("using: " +graphfile)
# if not os.path.exists(os.path.join(args.auxdir,".snap")):
# auxcmd = "docker cp esa-snap:/home/lozach/.snap "+args.auxdir
# p = subprocess.Popen(auxcmd, shell=True, env=my_env)
# p.wait()
i=0
for dataset in s1dir:
i+=1
my_env = os.environ.copy()
# my_env["PATH"] = "/work/esa-snap/Sen2Cor-02.05.05-Linux64/bin:" + my_env["PATH"]
spabspath = os.path.split(dataset)
filename = spabspath[-1]
spdataset = filename.split("_")
s1output = spabspath[0]+"/SnapCal/"+"_".join(spdataset[:5])+".dim"
i+=1
filename = os.path.basename(dataset)
s1output = os.path.join(args.outdir, filename[:lenext]+"dim")
cmd = "gpt "+graphfile+" -Pinput="+dataset+" -Poutput="+s1output
if args.docker:
cmd = "docker run "+optvoldata+" "+optvoluser+" esa-snap "+cmd
# if args.docker:
# cmd = "docker run "+optvoldata+" esa-snap "+cmd
#+" "+optvoluser
print("command : "+cmd)
p = subprocess.Popen(cmd, shell=True, env=my_env)
......
......@@ -828,7 +828,8 @@ if __name__ == "__main__":
list_parser.add_argument('-outtxt', action='store', required=True, help='Output text file where each Sentinel-1 dates correspond their model dry or wet to use')
list_parser.add_argument('--no-resampling', dest='resampling', action='store_false', help='[Optional] Resample GPM 100km to 10m, default false')
list_parser.set_defaults(resampling=False)
args=parser.parse_args()
# Apply CSV file on Labels file
list_parser = subparsers.add_parser('csvtomoist', help="Apply CSV results on labels raster to create moisture map")
......
......@@ -32,7 +32,7 @@ if __name__ == "__main__":
# Make parser object
parser = argparse.ArgumentParser(description=
"""
Perform Gapfilling over NDVI time serie.
Rename MV and NDVI
""")
parser.add_argument('-proddir', action='store', required=True, help='Directory containing Soil Moisture files (MV + NDVI) for a production site')
......@@ -58,7 +58,7 @@ if __name__ == "__main__":
for n in ndvis:
nsplit = os.path.basename(n)[:-4].split('_')
fdate = re.findall("20\d{6}",n)
fdate = re.findall("20\d{4}",n)
if not(fdate):
print("Impossible de trouver la date dans le nom de fichier : "+n)
exit
......
<graph id="Graph">
<version>1.0</version>
<node id="Read">
<operator>Read</operator>
<sources/>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<file>${input}</file>
<formatName>SENTINEL-1</formatName>
</parameters>
</node>
<node id="Calibration">
<operator>Calibration</operator>
<sources>
<sourceProduct refid="Read"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands/>
<auxFile>Product Auxiliary File</auxFile>
<externalAuxFile/>
<outputImageInComplex>false</outputImageInComplex>
<outputImageScaleInDb>false</outputImageScaleInDb>
<createGammaBand>false</createGammaBand>
<createBetaBand>false</createBetaBand>
<selectedPolarisations>VV</selectedPolarisations>
<outputSigmaBand>true</outputSigmaBand>
<outputGammaBand>false</outputGammaBand>
<outputBetaBand>false</outputBetaBand>
</parameters>
</node>
<node id="Terrain-Correction">
<operator>Terrain-Correction</operator>
<sources>
<sourceProduct refid="Calibration"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<sourceBands>Sigma0_VV</sourceBands>
<demName>SRTM 1Sec HGT</demName>
<externalDEMFile/>
<externalDEMNoDataValue>0.0</externalDEMNoDataValue>
<externalDEMApplyEGM>true</externalDEMApplyEGM>
<demResamplingMethod>BILINEAR_INTERPOLATION</demResamplingMethod>
<imgResamplingMethod>BILINEAR_INTERPOLATION</imgResamplingMethod>
<pixelSpacingInMeter>10.0</pixelSpacingInMeter>
<mapProjection>PROJCS[&quot;WGS 84 / UTM zone 30N&quot;,
GEOGCS[&quot;WGS 84&quot;,
DATUM[&quot;World Geodetic System 1984&quot;,
SPHEROID[&quot;WGS 84&quot;, 6378137.0, 298.257223563, AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],
AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],
PRIMEM[&quot;Greenwich&quot;, 0.0, AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],
UNIT[&quot;degree&quot;, 0.017453292519943295],
AXIS[&quot;Geodetic longitude&quot;, EAST],
AXIS[&quot;Geodetic latitude&quot;, NORTH],
AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]],
PROJECTION[&quot;Transverse_Mercator&quot;, AUTHORITY[&quot;EPSG&quot;,&quot;9807&quot;]],
PARAMETER[&quot;central_meridian&quot;, -3.0],
PARAMETER[&quot;latitude_of_origin&quot;, 0.0],
PARAMETER[&quot;scale_factor&quot;, 0.9996],
PARAMETER[&quot;false_easting&quot;, 500000.0],
PARAMETER[&quot;false_northing&quot;, 0.0],
UNIT[&quot;m&quot;, 1.0],
AXIS[&quot;Easting&quot;, EAST],
AXIS[&quot;Northing&quot;, NORTH],
AUTHORITY[&quot;EPSG&quot;,&quot;32630&quot;]]</mapProjection>
<alignToStandardGrid>false</alignToStandardGrid>
<standardGridOriginX>0.0</standardGridOriginX>
<standardGridOriginY>0.0</standardGridOriginY>
<nodataValueAtSea>true</nodataValueAtSea>
<saveDEM>false</saveDEM>
<saveLatLon>false</saveLatLon>
<saveIncidenceAngleFromEllipsoid>true</saveIncidenceAngleFromEllipsoid>
<saveLocalIncidenceAngle>false</saveLocalIncidenceAngle>
<saveProjectedLocalIncidenceAngle>false</saveProjectedLocalIncidenceAngle>
<saveSelectedSourceBand>true</saveSelectedSourceBand>
<outputComplex>false</outputComplex>
<applyRadiometricNormalization>false</applyRadiometricNormalization>
<saveSigmaNought>false</saveSigmaNought>
<saveGammaNought>false</saveGammaNought>
<saveBetaNought>false</saveBetaNought>
<incidenceAngleForSigma0>Use projected local incidence angle from DEM</incidenceAngleForSigma0>
<incidenceAngleForGamma0>Use projected local incidence angle from DEM</incidenceAngleForGamma0>
<auxFile>Latest Auxiliary File</auxFile>
<externalAuxFile/>
</parameters>
</node>
<node id="Write">
<operator>Write</operator>
<sources>
<sourceProduct refid="Terrain-Correction"/>
</sources>
<parameters class="com.bc.ceres.binding.dom.XppDomElement">
<file>${output}</file>
<formatName>BEAM-DIMAP</formatName>
</parameters>
</node>
<applicationData id="Presentation">
<Description/>
<node id="Read">
<displayPosition x="37.0" y="134.0"/>
</node>
<node id="Calibration">
<displayPosition x="133.0" y="138.0"/>
</node>
<node id="Terrain-Correction">
<displayPosition x="281.0" y="130.0"/>
</node>
<node id="Write">
<displayPosition x="455.0" y="135.0"/>
</node>
</applicationData>
</graph>
<!--
<pixelSpacingInDegree>8.983152841195215E-5</pixelSpacingInDegree>
<mapProjection>GEOGCS[&quot;WGS84(DD)&quot;,
DATUM[&quot;WGS84&quot;,
SPHEROID[&quot;WGS84&quot;, 6378137.0, 298.257223563]],
PRIMEM[&quot;Greenwich&quot;, 0.0],
UNIT[&quot;degree&quot;, 0.017453292519943295],
AXIS[&quot;Geodetic longitude&quot;, EAST],
AXIS[&quot;Geodetic latitude&quot;, NORTH]]</mapProjection>
-->
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment