Last active
February 23, 2017 22:29
-
-
Save rbiswas4/4b394d83368227ea393e5e857e64e4b5 to your computer and use it in GitHub Desktop.
script to change fieldIDs in sandwich mdoel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import glob | |
s = '# fields/userRegions_design.txt - design fields - 18,000 sq deg\n' | |
def writefile(fname, s, fieldDF): | |
with open(fname, 'r') as f: | |
data = f.read() | |
l = data.split(s) | |
with open(fname, 'w') as f: | |
f.write(l[0]) | |
f.write(s) | |
fieldDF[['fieldRA', 'fieldDec', 'width']].to_csv(fname, index=False, header=False, mode='a') | |
return None | |
fnames = glob.glob('Universal_N_*.conf') | |
df = pd.read_csv('Group_0.csv') | |
for fname in fnames: | |
writefile(fname, s=s, fieldDF=df) | |
fnames = glob.glob('Universal_M_*.conf') | |
df = pd.read_csv('Group_1.csv') | |
for fname in fnames: | |
writefile(fname, s=s, fieldDF=df) | |
fnames = glob.glob('Universal_S_*.conf') | |
df = pd.read_csv('Group_2.csv') | |
for fname in fnames: | |
writefile(fname, s=s, fieldDF=df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment