是否可以通过Python运行IDL程序?

时间:2019-06-14 15:35:03

标签: python idl-programming-language

我有一个IDL代码IDLcode.pro,并且我希望该代码能够在python脚本中运行。

我知道您可以使用pidly通过idl('cmd')通过python运行python的IDL命令,但是我想运行完整的(.pro)IDL程序。是否有python命令?

这是我想通过python运行的“ IDLcode.pro”程序

IDLcode.pro

idlout="$here/idl.out"
FormattedIDL="$here/FormattedIDL.txt"

function formatIDL {
cat $idlout | sed 's/  */ /g' | cut -d ' ' -f1 -f4 -f5 -f6 -f7 -f8 -f9 > $FormattedIDL
}

function buildKMZ {
kmzdir="$here/kmz"
mkdir $kmzdir
KML="$here/kmz/doc.kml"

name=$(head -n 1 $FormattedIDL | cut -d ' ' -f1 | cut -d '_' -f1 -f2)

echo '<?xml version="1.0" encoding="UTF-8"?>' > $KML
echo '<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">' >> $KML
echo "<Document id=\"LVIS - ${name}\">" >> $KML
echo "  <name>LVIS - ${name}</name>" >> $KML
echo '  <open>0</open>' >> $KML
echo '  <Snippet maxLines="0"></Snippet>' >> $KML
echo '<Folder>' >> $KML
echo "  <name>LVIS ${name}</name>" >> $KML
echo '  <Snippet maxLines="0"></Snippet>' >> $KML

IFS=$'\n'
for item in $(cat $FormattedIDL); do
    filename=$(echo $item | cut -d ' ' -f1)
    color=$(echo $item | cut -d ' ' -f6)
    rcolor=$(echo $item | cut -d ' ' -f7)

    lat1=$(echo $item | cut -d ' ' -f2)
    lon1=$(echo $item | cut -d ' ' -f3)
    lat2=$(echo $item | cut -d ' ' -f4)
    lon2=$(echo $item | cut -d ' ' -f5)

    echo '  <Placemark>' >> $KML
    echo '      <Snippet maxLines="0"></Snippet>' >> $KML
    echo '      <description><![CDATA[<html xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:msxsl="urn:schemas-microsoft-com:xslt">' >> $KML
    echo '                                  <head>' >> $KML
    echo '                                          <META http-equiv="Content-Type" content="text/html">' >> $KML
    echo '                                          <meta http-equiv="content-type" content="text/html; charset=UTF-8">' >> $KML
    echo '                                  </head>' >> $KML
    echo "                                  <body style=\"margin:0px 0px 0px 0px;overflow:auto;background:#${color};padding:5px;font-family:Arial,Verdana,Times;font-size:12px\">$filename</html>]]></description>" >> $KML
    echo '          <Style>' >> $KML
    echo '              <LineStyle>' >> $KML
    echo "                  <color>${rcolor}</color>" >> $KML
    echo '                  <width>5.0</width>' >> $KML
    echo '              </LineStyle>' >> $KML
    echo '      </Style>' >> $KML
    echo '      <LineString>' >> $KML
    echo '          <coordinates>' >> $KML
    echo "$lon1,$lat1,0 $lon2,$lat2,0" >> $KML
    echo '          </coordinates>' >> $KML
    echo '      </LineString>' >> $KML
    echo '  </Placemark>' >> $KML
done
echo '</Folder>' >> $KML
echo '</Document>' >> $KML
echo '</kml>' >> $KML

cd $kmzdir
zip -r $(dirname $FullTraj)/${name}_${Flight}.kmz .


formatIDL
buildKMZ

0 个答案:

没有答案