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)
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)
def test_getirramp(self): """Make sure get_irramp works""" d = gini.get_ir_ramp() self.assertEqual(len(d), 256)
def test_getirramp(): """Make sure get_irramp works""" d = gini.get_ir_ramp() assert len(d) == 256