from glob import glob from os.path import join import re ################################################################################ ##### cse2rat.py, v1.1 ##### ##### Originally written in 2015 by Paul M. Woods. ##### ##### This script automatically generates input files for RATRAN, from ##### ##### the public circumstellar envelope code available at http://udfa.net ##### ##### This code is distributed under the terms of the MIT License (MIT) ##### ##### # ##### Copyright (c) 2015 Dr. Paul M. Woods # ##### # #Permission is hereby granted, free of charge, to any person obtaining a copy # #of this software and associated documentation files (the "Software"), to deal # #in the Software without restriction, including without limitation the rights # #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # #copies of the Software, and to permit persons to whom the Software is # #furnished to do so, subject to the following conditions: # # # #The above copyright notice and this permission notice shall be included in all# #copies or substantial portions of the Software. # # # #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # #SOFTWARE. # ##### ##### ################################################################################ #Turn on (1) or off (0) user interaction interaction = 0 # Molecule of interest or 'ALL' for all molecules for which there is collisional data specString = 'SiS' elecString = 'e-' tempString = 'TEMP.' vexp = 14.5 db = 1.0 ratranPath = '/Users/abc/Work/RATRAN/Ratran/' # Input file from CSE code dataFile = open('csnum_rate13.out','rb') # Get input parameters directly from user if interaction ==1: specString = raw_input("Please enter species name, exactly as in Rate12: ") vexp = raw_input("Give the expansion velocity of the envelope, in km/s: ") vexp = float(vexp) ratranPath = raw_input("Provide the absolute path to the RATRAN directory, including a trailing slash: ") dataFilename = raw_input("Please enter the CSE model datafile you would like to use. N.B. this must be a file containing number densities: ") dataFile = open(dataFilename) # A dictionary to convert LAMDA filenames to UDFA species names; # second element of the tuple is the transitions within ALMA windows. Use getTrans.py to generate these. fileToMol = { '13co.dat': ('','1,2,3,4,6,8'), '29sio.dat': ('','2,3,5,6,7,8,9,10,11,15,16,19,20,21,22'), 'a-ch3oh.dat': ('CH3OH','49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691'), 'c+.dat': ('C+',''), 'c+@uv.dat': ('','1,2'), 'c17o.dat': ('','1,2,3,4,6,8'), 'c18o.dat': ('','1,2,3,4,6,8'), 'c2h_h2_e.dat': ('C2H','1,2,3,4,5,6,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,95,96,97,98,99,100,101,102,103,104,105'), 'catom.dat': ('C','1,2'), 'ch3cn.dat': ('CH3CN',''), 'cn.dat': ('CN','1,2,3,4,5,6,7,8,9,10,11,15,16,17,18,19,20,21,22,23'), 'co.dat': ('CO','1,2,3,4,6,7,8'), 'co@neufeld.dat': ('','1,2,3,4,6,7,8'), 'co@old.dat': ('','1,2,3,4,6,7,8'), 'cs@lique.dat': ('CS','2,3,5,6,7,8,9,10,13,14,17,18,19'), 'dco+@xpol.dat': ('','2,3,4,5,6,9,11,12,13'), 'e-ch3oh.dat': ('CH3OH','79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,715,716,717,718,719,720,721,722,723,724,725,726,727,728,729,730,731,732,733,734,735,736,737,738,739,740,741,742,743,744,745,746,747,748,749,750,751,752,753,754,755,756,757,758,759,760,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,923,924,925,926,927,928,929,930,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1021,1022,1023,1024,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059'), 'h13cn@xpol.dat': ('','1,3,4,5,7,8,10,11'), 'h13co+@xpol.dat': ('','1,3,4,5,7,8,10'), 'hc15n@xpol.dat': ('','1,3,4,5,7,8,10,11'), 'hc17o+@xpol.dat': ('','1,3,4,5,7,8,10'), 'hc18o+@xpol.dat': ('','1,3,4,5,8,10,11'), 'hc3n.dat': ('HC3N','10,11,12,14,15,16,17'), 'hcl.dat': ('HCl','1'), 'hcl@hfs.dat': ('','1,2,3'), 'hcn.dat': ('HCN','1,3,4,5,7,8,9,10'), 'hcn@hfs.dat': ('','1,2,3,7,8,9,11,12,13,14'), 'hcn@xpol.dat': ('','1,3,4,5,7,8,9,10'), 'hco+.dat': ('HCO+','1,3,4,5,7,8,9,10'), 'hco+@xpol.dat': ('','1,3,4,5,7,8,9,10'), 'hcs+@xpol.dat': ('HCS+','2,3,5,6,7,8,10,11,15,16,19,20,21,22'), 'hdo.dat': ('','1,2,5,6,7,9,20,25,26,44,45,52,63,72,97,104,105,113'), 'hf.dat': ('HF',''), 'hnc.dat': ('HNC','1,3,4,5,7,9,10'), 'hnco.dat': ('HNCO','34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,86,87,88,93,94,95,96,97,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123'), 'n2h+@xpol.dat': ('N2H+','1,3,4,5,7,9,10'), 'n2h+_hfs.dat': ('','1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129'), 'no.dat': ('NO','253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694'), 'o-c3h2.dat': ('C3H2','20,21,22,23,24,25,26,27,28,29,30,38,39,40,41,42,43,44,45,46,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,134,135,136,137,138,139,140,141,142,143,148,149,150,151,152,153,154'), 'o-h3o+.dat': ('H3O+','3'), 'o-nh2d.dat': ('',''), 'o-nh3.dat': ('NH3',''), 'o-sic2.dat': ('SiC2','17,18,19,20,25,26,27,28,29,30,31,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78'), 'o2.dat': ('O2','33,34,35,36,38'), 'oatom.dat': ('O',''), 'ocs@xpol.dat': ('OCS','7,8,9,11,12,13,18,19,20,21,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40,41,50,51,52,53,54,55,56,57,58,59,65,66,67,68,69,70,71,72,73,74,75,76,77,78'), 'oh+.dat': ('OH+',''), 'oh.dat': ('OH',''), 'oh2co-h2.dat': ('H2CO','2,4,5,7,8,10,11,14,15,16,17,18,28,33,39,44,48,49,50,51,56,60,70,82,83,84,89,93,94,95'), 'oh2cs.dat': ('H2CS','4,6,7,9,16,18,19,20,21,23,26,28,31,32,33,35,36,38,40,43,45,48,50,51,54'), 'oh2o@daniel.dat': ('H2O','17,32,57,90,144'), 'oh2o@rovib.dat': ('','17,38,67,112,148,218,235,254,278,410,474,527,550,635,834,850,886,1066,1164,1206,1281,1324,1458,1575,1738,1761,1846,1904,2064,2262,2369,2477,2519,2566,2686,2707,2758,2836,2880,2957,3027,3053,3212,3214,3294,3409,3440,3514,3604,3643,3749,3762,3876,4220,4347,4415,4966,4998,5031,5082,5083,5183,5224,5341,5342,5359,5401,5443,5615,5822,6193,6396,6435,6436,6481,6586,6587,6699,6857,6858,6908,7188,7317,7503'), 'oh2s.dat': ('H2S','7,9,14,17,21,35,37,42,63,66,89,95,98,103,118'), 'oh@hfs.dat': ('','51,60'), 'p-c3h2.dat': ('','19,20,21,22,23,24,25,26,27,34,35,36,37,38,39,40,41,42,43,44,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,134,135,136,137,138,139,140,148,149,150,151,152'), 'p-h3o+.dat': ('','1,5,12'), 'p-nh2d.dat': ('',''), 'p-nh3.dat': ('',''), 'ph2co-h2.dat': ('','2,3,4,5,10,13,14,16,17,20,21,24,27,30,33,34,40,43,47,50,51,54,55,67,70,75,79,84,90,91,94,95'), 'ph2cs.dat': ('','3,4,6,7,9,10,11,18,19,21,22,24,25,27,28,30,31,34,37,40,46,49,52,53'), 'ph2o@daniel.dat': ('','17,29,34,58,70,94,113'), 'ph2o@rovib.dat': ('','19,21,38,45,71,115,118,192,227,231,282,350,449,502,545,558,760,899,928,990,1060,1208,1471,1688,1705,1773,1971,1989,1990,2121,2186,2258,2386,2455,2509,2526,2551,2653,2668,2755,2756,2775,2802,2860,3120,3121,3196,3382,3453,3508,3532,3587,3752,3964,3965,4189,4224,4349,4655,4775,4805,4838,4893,5045,5257,5352,5458,5684,5901,6162,6244,6288,6289,6427,6628,6710,6848,7176,7223,7295'), 'ph2s.dat': ('','1,2,4,5,7,19,24,26,27,30,42,45,60,65,67,93,102,115'), 'sio.dat': ('SiO','2,3,5,6,7,8,9,10,11,14,15,16,19,20,21'), 'sis.dat': ('SiS','5,6,7,8,12,13,14,15,16,17,18,19,20,22,23,24,25,26,27,34,35,36,37,38,39'), 'so2.dat': ('SO2','48,49,50,51,52,53,54,55,56,57,58,59,60,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562'), 'so@lique.dat': ('SO','3,4,5,6,7,8,10,11,12,14,15,16,17,18,21,22,24,26,27,28,34,35,36,37,39,41,42,44,47,48,49,50,51,52,55,56,57,58,59,62,63,65,66,68,70,71,72,73,75,77,78,82,84,85,87,89,90,92,93,94,95,96,98,99,101,102,104,107,108,110,111,113,117,122,125,129,132,137,138,142,144,147,149,150,154,155,158,159,161,162,166,167,170,171,173,182,185,190,192,194,197,198,202,203,204,207,209,210,213,214,215,218,220,221,224,225,229,231,232,236,237,239,241,246,250,255,259,264') } # Set up list to hold the required species requiredSpec = [] if specString == 'ALL': availableSpec = [] molFilePaths = glob(join(ratranPath,'molec','*.dat')) amcALLFile = open(ratranPath+'ALLamc.inp','w') skyALLFile = open(ratranPath+'ALLsky.inp','w') for i, x in enumerate(molFilePaths): availableSpec.append(re.search(r'([^/]+$)',x).group(1)) for x in availableSpec: requiredSpec.append(fileToMol[x][0]) else: requiredSpec.append(specString) # Flag to indicate initial loop through species subLoop = 0 # Generate a list of non-empty entries (generator object) gen = (x for x in requiredSpec if x) for x in gen: specString = x specLoc = [] specAbund = [] elecLoc = [] elecAbund = [] tempLoc = None radius = [] density = [] temperature = [] # Output files (for RATRAN) outFile = open(ratranPath+specString+'input.mdl','w') amcFile = open(ratranPath+specString+'amc.inp','w') skyFile = open(ratranPath+specString+'sky.inp','w') # Assumption: radius, density and temperature are the first three columns in the row # Get the location of key lines in the data file for num, line in enumerate(dataFile, 0): # Find our species of interest, and store its abundance if ' '+specString+' ' in line: specLoc.append(num) if len(specLoc) == 1: if num == specLoc[0]: specIndex = line.split().index(specString) specAbund.append(line.split()[specIndex]) # Find the electron abundance, store it if elecString in line: elecLoc.append(num) if len(elecLoc) == 1: if num == elecLoc[0]: elecIndex = line.split().index(elecString) elecAbund.append(line.split()[elecIndex]) # Find the line of the file with the physical parameters if tempString in line: tempLoc = num if tempLoc is not None: if (num - tempLoc) <= len(specAbund) - 1: radius.append(line.split()[0]) density.append(line.split()[1]) temperature.append(line.split()[2]) dataFile.seek(0) if len(specAbund) == 0: print "Species",specString,"not found." if len(elecAbund) == 0: print "Electrons",elecString,"not found." if len(radius) == 0: print "Temperature (",tempString,") not found." # Print the output .mdl file in RATRAN format outFile.write('# Input model file for RATRAN. Source: UDFA CSE model.\n') outFile.write('# Radii in m, temperatures in K, abundances are number densities.\n') outFile.write('# Molecule:'+repr(specString)+'\n') outFile.write('rmax={0:11.5E}\n'.format(float(radius[-1])/100.)) outFile.write('ncell='+str(len(radius)-2)+'\n') outFile.write('tcmb=2.728\ncolumns=id,ra,rb,nh,nm,tk,db,vr\ngas:dust=100\n@\n') # N.B. Radius must be in m, radius[1] must be zero. radius[1] = 0.0 for i in range(1,len(radius)-1): outFile.write('{0:4d} {1:12.5E} {2:12.5E} {3:12.5E} {4:12.5E} {5:12.5E} {6:4.1f} {7:5.1f} \n'.format(i,float(radius[i])/100.,float(radius[i+1])/100.,float(density[i]),float(specAbund[i]),float(temperature[i]),db,vexp)) outFile.close() # Write amc.inp file # Recover molecular input filename from dictionary. N.B. Will only take FIRST match. for k, v in fileToMol.iteritems(): if v[0] == specString: molFile = k molTrans = v[1] break # kappa=jena,bare,no # kappa=powerlaw,2.746E11,6.17E-4,1.0 amcFile.write('source='+specString+'input.mdl\noutfile='+specString+'.pop\nmolfile='+molFile+'\nsnr=20\nnphot=1000\nvelo=grid\nkappa=jena,bare,no\nseed=1978\ngo\nq\n') amcFile.close() try: amcALLFile.closed if subLoop == 0: amcALLFile.write('source='+specString+'input.mdl\noutfile='+specString+'.pop\nmolfile='+molFile+'\nsnr=20\nnphot=1000\nvelo=grid\nkappa=jena,bare,no\nseed=1978\ngo\n') subLoop = 1 else: amcALLFile.write('c\nsource='+specString+'input.mdl\noutfile='+specString+'.pop\nmolfile='+molFile+'\ngo\n') except: pass # Write sky.inp file skyFile.write('source='+specString+'.pop\nformat=fits\noutfile='+specString+'.sky\ntrans='+molTrans+'\npix=256,1.0,32,5\nchan=99,0.1\ndistance=133.\nincl=90.\nunits=K\ngo\nq') skyFile.close() try: skyALLFile.closed if subLoop == 1: skyALLFile.write('source='+specString+'.pop\nformat=fits\noutfile='+specString+'.sky\ntrans='+molTrans+'\npix=256,1.0,32,5\nchan=99,0.1\ndistance=133.\nincl=90.\nunits=K\ngo\n') subLoop = 2 else: skyALLFile.write('c\nsource='+specString+'.pop\noutfile='+specString+'.sky\ntrans='+molTrans+'\ngo\n') except: pass dataFile.close() try: amcALLFile.closed amcALLFile.write('q\n') amcALLFile.close() skyALLFile.write('q\n') skyALLFile.close() except: pass print "DONE!"