Skip to content

Commit eeaa9df

Browse files
committed
Added script for to form in which it will run
modified: scripts/recalculate_opsimvalues.py - Fixed script - realized it was the was the wrong one and fixed bugs - added versioning information modified: ../obscond/version.py - bumped version - put in version Versioning information for obscond in script modified: recalculate_opsimvalues.py Added __version__ modified: obscond/__init__.py
1 parent fc09dc1 commit eeaa9df

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

obscond/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
from .constants import *
66
from .atmosphere import *
77
from .skybrightness import *
8-
#from .version import __version__
8+
from .version import __version__
99
dirname = os.path.dirname(os.path.abspath(__file__))
1010
example_data_dir = os.path.join(dirname, 'example_data')

obscond/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.4.0"
1+
__version__ = "0.4.1"

scripts/recalculate_opsimvalues.py

+22-12
Original file line numberDiff line numberDiff line change
@@ -37,50 +37,60 @@
3737
# Read the opsim data base and start logging
3838
logging.basicConfig(level=logging.INFO)
3939
logger = logging.getLogger(__name__)
40+
tstart = time.time()
41+
logger.info('Start Program at time {}'.format(tstart))
4042
print('Healpy version: ', hp.__version__)
4143
print('numpy version: ', np.__version__)
4244
print('healpy dir', getPackageDir('healpy'))
4345
print('sims_skybrightness_dir', getPackageDir('sims_skybrightness'))
4446
print('sims_skybrightness_data_dir', getPackageDir('sims_skybrightness_data'))
47+
print('obscond version', obscond.__version__)
4548

4649
logger.info('Start reading opsim database')
47-
# minion_out = '/local/lsst/rbiswas/data/LSST/OpSimData/minion_1016_sqlite.db'
48-
minion_out = '/Users/rbiswas/data/LSST/OpSimData/minion_1016_sqlite.db'
50+
minion_out = '/local/lsst/rbiswas/data/LSST/OpSimData/minion_1016_sqlite.db'
51+
#minion_out = '/Users/rbiswas/data/LSST/OpSimData/minion_1016_sqlite.db'
4952
opsout = OpSimOutput.fromOpSimDB(minion_out, zeroDDFDithers=True, subset="unique_all")
50-
print('reading done')
51-
df = opsout.summary.copy().iloc[:100]
53+
# opsout = OpSimOutput.fromOpSimDB(minion_out, zeroDDFDithers=True, subset="ddf")
54+
print('reading done\n')
55+
df = opsout.summary.copy()
5256
logger.info('Finished reading database at {}'.format(time.time()))
5357

5458
totalbpdict, hwbpdict = BandpassDict.loadBandpassesFromFiles()
5559
photparams = PhotometricParameters()
5660

5761

5862
# Split the entries in the opsim database for parallelization
59-
splits = 10
63+
splits = 1000
6064
dfs = np.array_split(df, splits)
61-
print('splitting dataframe of size {0} into {1} splits each of size {2}'.format(len(df), splits, len(dfs[0])))
65+
print('splitting dataframe of size {0} into {1} splits each of size {2}\n'.format(len(df), splits, len(dfs[0])))
6266

6367
calcdfs = []
6468
def recalcmags(j):
6569
logfname = 'newres_{}.log'.format(j)
70+
tsplitstart = time.time()
6671
with open(logfname, 'w') as f:
67-
f.write('starting split {} \n'.format(j))
72+
f.write('starting split {0} at time {1}\n'.format(j, tsplitstart))
6873
df = dfs[j]
6974
sm = sb.SkyModel(observatory='LSST', mags=False, preciseAltAz=True)
7075
skycalc = obscond.SkyCalculations(photparams="LSST", hwBandpassDict=hwbpdict)
7176

7277
fname = 'newres{}.hdf'.format(j)
7378
df_res = skycalc.calculatePointings(df)
7479
with open(logfname, mode='a+') as f:
75-
f.write('dataframe calculated')
80+
f.write('dataframe calculated\n')
7681
df_res.to_hdf(fname, key='0')
82+
tsplitend = time.time()
7783
with open(logfname, mode='a+') as f:
78-
f.write('dataframe written')
79-
return df
84+
f.write('dataframe written at time {} \n'.format(tsplitend))
85+
f.write('For dataframe of size {0} time taken is {1}\n'.format(len(df_res), tsplitend - tsplitstart))
86+
return df_res
8087

8188
ndf = Parallel(n_jobs=-1)(delayed(recalcmags)(j=j) for j in range(splits))
82-
print('After loops are over, this is the number of dataframes', len(ndf))
89+
print('After loops are over, this is the number of dataframes\n', len(ndf))
8390
newdf = pd.concat(ndf)
84-
print('number of lines {}'.format(len(newdf)))
91+
print('number of lines {}\n'.format(len(newdf)))
8592
newdf.to_hdf('newOpSim.hdf', key='0')
93+
tend = time.time()
94+
logger.info('End Program at time {} sec'.format(tend))
95+
logger.info('Time taken is {} sec'.format(tend - tstart))
8696
print('DONE')

0 commit comments

Comments
 (0)