示例#1
0
文件: gini2gis.py 项目: xlia/pyWWA
def write_gispng(sat, tmpfn):
    """
    Write PNG file with associated .wld file.
    """

    if sat.get_channel() == "IR":
        do_legacy_ir(sat, tmpfn)
        # Make enhanced version
        png = Image.fromarray(np.array(sat.data[:-1, :], np.uint8))
        png.putpalette(tuple(gini.get_ir_ramp().ravel()))
    else:
        png = Image.fromarray(np.array(sat.data[:-1, :], np.uint8))
    png.save("%s.png" % (tmpfn, ))

    # World File
    out = open("%s.wld" % (tmpfn, ), "w")
    fmt = """%(dx).3f
0.0
0.0
-%(dy).3f
%(x0).3f
%(y1).3f"""
    out.write(fmt % sat.metadata)
    out.close()

    cmd = ("%s -i -p 'gis %s %s gis/images/awips%s/%s GIS/sat/awips%s/%s png' "
           "%s.png") % (
               PQINSERT,
               get_ldm_routes(sat),
               sat.metadata["valid"].strftime("%Y%m%d%H%M"),
               sat.awips_grid(),
               sat.current_filename(),
               sat.awips_grid(),
               sat.archive_filename(),
               tmpfn,
           )
    subprocess.call(cmd, shell=True)

    cmd = ("%s -i -p 'gis %s %s gis/images/awips%s/%s GIS/sat/awips%s/%s wld' "
           "%s.wld") % (
               PQINSERT,
               get_ldm_routes(sat),
               sat.metadata["valid"].strftime("%Y%m%d%H%M"),
               sat.awips_grid(),
               sat.current_filename().replace("png", "wld"),
               sat.awips_grid(),
               sat.archive_filename().replace("png", "wld"),
               tmpfn,
           )
    subprocess.call(cmd, shell=True)
示例#2
0
文件: gini2gis.py 项目: akrherz/pyWWA
def write_gispng(sat, tmpfn):
    """
    Write PNG file with associated .wld file.
    """

    if sat.get_channel() == "IR":
        do_legacy_ir(sat, tmpfn)
        # Make enhanced version
        png = Image.fromarray(np.array(sat.data[:-1, :], np.uint8))
        png.putpalette(tuple(gini.get_ir_ramp().ravel()))
    else:
        png = Image.fromarray(np.array(sat.data[:-1, :], np.uint8))
    png.save('%s.png' % (tmpfn,))

    # World File
    out = open('%s.wld' % (tmpfn,), 'w')
    fmt = """%(dx).3f
0.0
0.0
-%(dy).3f
%(x0).3f
%(y1).3f"""
    out.write(fmt % sat.metadata)
    out.close()

    cmd = ("%s -i -p 'gis %s %s gis/images/awips%s/%s GIS/sat/awips%s/%s png' "
           "%s.png"
           ) % (PQINSERT, get_ldm_routes(sat),
                sat.metadata['valid'].strftime("%Y%m%d%H%M"),
                sat.awips_grid(), sat.current_filename(),
                sat.awips_grid(), sat.archive_filename(), tmpfn)
    subprocess.call(cmd, shell=True)

    cmd = ("%s -i -p 'gis %s %s gis/images/awips%s/%s GIS/sat/awips%s/%s wld' "
           "%s.wld"
           ) % (PQINSERT, get_ldm_routes(sat),
                sat.metadata['valid'].strftime("%Y%m%d%H%M"), sat.awips_grid(),
                sat.current_filename().replace("png", "wld"), sat.awips_grid(),
                sat.archive_filename().replace("png", "wld"), tmpfn)
    subprocess.call(cmd, shell=True)
示例#3
0
 def test_getirramp(self):
     """Make sure get_irramp works"""
     d = gini.get_ir_ramp()
     self.assertEqual(len(d), 256)
示例#4
0
def test_getirramp():
    """Make sure get_irramp works"""
    d = gini.get_ir_ramp()
    assert len(d) == 256
示例#5
0
 def test_getirramp(self):
     """Make sure get_irramp works"""
     d = gini.get_ir_ramp()
     self.assertEqual(len(d), 256)