def mosaic(demlist, outname, byteorder=1, gammapar=True):
    nodata = str(raster.Raster(demlist[0]).nodata)
    run(
        dissolve([
            "gdalwarp", "-q", "-of", "ENVI", "-srcnodata", nodata,
            "-dstnodata", nodata, demlist, outname
        ]))
    if byteorder == 1:
        swap(outname, outname + "_swap")
        for item in [outname, outname + ".hdr", outname + ".aux.xml"]:
            os.remove(item)
        os.rename(outname + "_swap", outname)
        os.rename(outname + "_swap.hdr", outname + ".hdr")
    if gammapar:
        dempar(outname)
Esempio n. 2
0
# Kennaugh matrix derivation from scattering matrix elements
# module of software gammaGUI
# John Truckenbrodt 2015
##############################################################
import os

from ancillary import grouping, dissolve

path_log = os.path.join(os.getcwd(), "LOG/LAT/")
if not os.path.exists(path_log):
    os.makedirs(path_log)

# create list of scene tuple objects
tuples = grouping()

print "#############################################"
print "creating kennaugh decomposition..."

for scene in tuples:
    print scene.main
    items = [
        getattr(scene, x) if hasattr(scene, x) else "-"
        for x in ["t11", "t22", "t33", "t12", "t13", "t23"]
    ]
    cmd = dissolve(
        ["KENNAUGH_MATRIX", items,
         os.path.join(scene.main, scene.basename)])
    print cmd

print "...done"
print "#############################################"
Esempio n. 3
0
path_log = os.path.join(os.getcwd(), "LOG/LAT/")
if not os.path.exists(path_log):
    os.makedirs(path_log)

# create list of scene tuple objects
tuples = grouping()

counter = 0
for tag in [
        "HH", "VV", "HV", "VH", "pauli_alpha", "pauli_beta", "pauli_gamma",
        "ctd_1_mag", "ctd_2_mag", "ctd_3_mag", "fdd_pd", "fdd_ps", "fdd_pv"
]:

    # collect processing candidates
    processlist = dissolve(
        [[getattr(scene, x) for x in scene.index if re.search(tag, x)]
         for scene in tuples])

    if tnorm:
        processlist = [
            x for x in processlist
            if re.search("_norm_geo$", x) and not os.path.isfile(x + "_tfilt")
        ]
    else:
        processlist = [
            x for x in processlist if re.search("_geo$", x) and "norm" not in x
            and not os.path.isfile(x + "_tfilt")
        ]

    if len(processlist) > 1:
        counter += 1
Esempio n. 4
0
nodata = ["-dstnodata", nodata]
format = ["-of", "ENVI"]
resampling = ["-r", resampling]

# find all files matching the defined pattern(s)
items = finder(path_in, pattern.split(", "), regex=True if reg == "True" else False)

if len(items) > 0:
    path_out = os.path.dirname(file_out)
    if not os.path.exists(path_out):
        os.makedirs(path_out)
    print "the following files will be stacked to file {0}:".format(file_out)
    for item in items:
        print item
    decision = raw_input("proceed (y/n)?: ")
    if decision == "y":
        vrt = file_out+".vrt"
        sp.check_call(dissolve(["gdalbuildvrt", "-q", "-overwrite", "-separate", vrt, items]))
        sp.check_call(dissolve(["gdalwarp", "-q", "-overwrite", resampling, format, nodata, extent, targetres, vrt, file_out]))
        os.remove(vrt)

        # add band names (basenames of the original files without extension) to the envi header file
        par = HDRobject(file_out+".hdr")
        par.band_names = [os.path.splitext(os.path.basename(x))[0] for x in items]
        hdr(par)
    else:
        print "command aborted"
else:
    print "no files matching the defined pattern(s) found"
Esempio n. 5
0
        run(["gc_map_fine", lut_rough, samples_dem, diffpar, lut_fine, 1], path_out, path_log)

        for item in [lut_rough, sim_map, sim_rdc]:
            os.remove(item)
    else:
        # read additional parameters
        samples_dem = ReadPar(dem_sub + ".par").width
        samples_mli = ReadPar(masterpar).range_samples

    # perform topographic normalization
    if tnorm:
        print "----------"
        # define regular expressions for images to be normalized (mli, fd3c decomp, cloude decomp)
        normtags = ["_mli$", "fdd_p[dsv]$", "ctd_[123]_mag$"]
        # create a list containing the actual image names including their absolute directory paths (only if the corresponding normalized processing result does not yet exist)
        normlist = dissolve([getattr(scene, x) for x in scene.index for tag in normtags if re.search(tag, x)])
        normlist = [x for x in normlist if not os.path.isfile(x+"_norm")]
        if len(normlist) > 0:
            print "topographic normalization\n----------"
            for image in normlist:
                print os.path.basename(image)
                topo_base = os.path.join(path_out, os.path.basename(image))
                pix_gamma = topo_base+"_pix_gamma"
                pix_gamma0ratio = topo_base+"_pix_gamma0ratio"
                ellip_pix_gamma0 = topo_base+"_ellip_pix_gamma0"
                parfile = image+".par" if re.search("_mli$", image) else getattr(scene, "HH_mli")+".par"
                # refined pixel area estimation
                run(["pixel_area", parfile, dem_sub+".par", dem_sub, lut_fine, ls_map, inc, "-", pix_gamma], path_out, path_log)
                run(["radcal_MLI", image, parfile, "-", "temp", "-", "-", "-", 2, "-", "-", ellip_pix_gamma0], path_out, path_log)
                width_mli = ReadPar(parfile).range_samples
                run(["ratio", ellip_pix_gamma0, pix_gamma, pix_gamma0ratio, width_mli, 1, 1, 0], path_out, path_log)