Beispiel #1
0
import argparse

import auxiliary as aux
import numlte as nl
import pyfi as fh

### Fix description
parser = argparse.ArgumentParser(
    description="Calculates Column Densities from one input file with molecular and brightness information"
)
parser.add_argument("infile", type=str, help="Input file")
parser.add_argument("outfile", type=str, help="Output file")
args = parser.parse_args()

filein = open(args.infile, "r")
fileaslist = fh.strip_off_comm(filein, "#")
filein.close()

values = fh.float_file(fileaslist, skip=[0, 1, 2])
fileout = open(args.outfile, "w")  # real option
aux.writeInfo(fileout, "MiniTex")
fileout.write(
    "#Source[1] Molecule[2] Transition[3] Frequency(GHz)[4] Opacity[5] sig(Opacity)[6] Intensity(K)[7] sig(intensity)(K)[8] Exc. Temp.(K)[9] sig(Exc. temp.)(K)[10]"
)
for i in range(len(values)):
    value = values[i]
    line = fileaslist[i]
    results = nl.calc_tex(value[1], value[2], value[3], value[4], value[0])
    fileout.write(line[:-1] + "\t{0:.4f}\t{1:.4f}\n".format(results[0], results[1]))
fileout.close()
Beispiel #2
0
    for idens in range(ndens + 1):
        for icol in range(ncoldens + 1):

            dens = nmin * ((nmax / nmin) ** (float(idens) / ndens))
            colden = colmin * ((colmax / colmin) ** (float(icol) / ncoldens))
            dv = deltav
            write_input(infile, temp, dens, colden, dv)
            i += 1
            if (i == (len(temps) * (ndens + 1) * (ncoldens + 1))):
                infile.write('0\n')
                infile.close()
            else:
                infile.write('1\n')

os.system(aux.radex + ' < /tmp/radex.inp > /dev/null')

stop = time.time()
dure = stop - start
print "Run time = ", dure, "seconds"
os.system('mv radex.log /tmp/')
output = open(args.output, 'w')
aux.writeInfo(output, "Gridder")
output.write(
    "#   Tkin     Density       Cdens     Eup        Freq       Wavel        Tex        Tau         TR        Pop        Pop       flux       flux     Jup  Jlow\n")
output.write(
    "#      K        cm-3        cm-2       K         GHz        micr          K          -          K         Up        Low     K km/s  erg/cm2/s\n")
output.write(
    "#Col   1           2           3       4           5           6          7          8          9         10         11         12         13      14    15\n")
output.close()
os.system('grep -v \'!\' /tmp/radex.out >> ' + args.output)
Beispiel #3
0
import auxiliary as aux
import numlte as nl
import pyfi as fh

### Fix description
parser = argparse.ArgumentParser(
    description="Calculates Column Densities from one input file with molecular and brightness information")
parser.add_argument("infile", type=str, help="Input file")
parser.add_argument("outfile", type=str, help="Output file")
args = parser.parse_args()

filein = open(args.infile, "r")

fileaslist = fh.strip_off_comm(filein, "#")
filein.close()

values = fh.float_file(fileaslist, skip=[0, 1, 2])
fileout = open(args.outfile, 'w')  # real option
aux.writeInfo(fileout,"MiniCol")
fileout.write("#Source[1] Molecule[2] Transition[3] Frequency (GHz)[4] Einstein Coef.(s^{-1})[5] En. Upper j(K)[6] Lower j[7]")
fileout.write(
    " Partition Func Q[8] Exc. Temp.(K)[9] sig(Exc. temp.)(K)[10] Opacity/Integ. int.(0|K*km/s)[11] sig(Opacity/Integ. int.)(0|K*km/s)[12]")
fileout.write(
    " Line width(km/s)[13] sig(Line width)(km/s)[14] Column dens.(cm^{-2})[15] sig(Column dens.(cm^{-2}))[16]\n")
for i in range(len(values)):
    value = values[i]
    line = fileaslist[i]
    results = nl.coldens(*value)
    fileout.write(line[:-1] + "\t{0:.4e}\t{1:.4e}\n".format(results[0], results[1]))
fileout.close()