|
37 | 37 | # Read the opsim data base and start logging
|
38 | 38 | logging.basicConfig(level=logging.INFO)
|
39 | 39 | logger = logging.getLogger(__name__)
|
| 40 | +tstart = time.time() |
| 41 | +logger.info('Start Program at time {}'.format(tstart)) |
40 | 42 | print('Healpy version: ', hp.__version__)
|
41 | 43 | print('numpy version: ', np.__version__)
|
42 | 44 | print('healpy dir', getPackageDir('healpy'))
|
43 | 45 | print('sims_skybrightness_dir', getPackageDir('sims_skybrightness'))
|
44 | 46 | print('sims_skybrightness_data_dir', getPackageDir('sims_skybrightness_data'))
|
| 47 | +print('obscond version', obscond.__version__) |
45 | 48 |
|
46 | 49 | 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' |
49 | 52 | 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() |
52 | 56 | logger.info('Finished reading database at {}'.format(time.time()))
|
53 | 57 |
|
54 | 58 | totalbpdict, hwbpdict = BandpassDict.loadBandpassesFromFiles()
|
55 | 59 | photparams = PhotometricParameters()
|
56 | 60 |
|
57 | 61 |
|
58 | 62 | # Split the entries in the opsim database for parallelization
|
59 |
| -splits = 10 |
| 63 | +splits = 1000 |
60 | 64 | 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]))) |
62 | 66 |
|
63 | 67 | calcdfs = []
|
64 | 68 | def recalcmags(j):
|
65 | 69 | logfname = 'newres_{}.log'.format(j)
|
| 70 | + tsplitstart = time.time() |
66 | 71 | 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)) |
68 | 73 | df = dfs[j]
|
69 | 74 | sm = sb.SkyModel(observatory='LSST', mags=False, preciseAltAz=True)
|
70 | 75 | skycalc = obscond.SkyCalculations(photparams="LSST", hwBandpassDict=hwbpdict)
|
71 | 76 |
|
72 | 77 | fname = 'newres{}.hdf'.format(j)
|
73 | 78 | df_res = skycalc.calculatePointings(df)
|
74 | 79 | with open(logfname, mode='a+') as f:
|
75 |
| - f.write('dataframe calculated') |
| 80 | + f.write('dataframe calculated\n') |
76 | 81 | df_res.to_hdf(fname, key='0')
|
| 82 | + tsplitend = time.time() |
77 | 83 | 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 |
80 | 87 |
|
81 | 88 | 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)) |
83 | 90 | newdf = pd.concat(ndf)
|
84 |
| -print('number of lines {}'.format(len(newdf))) |
| 91 | +print('number of lines {}\n'.format(len(newdf))) |
85 | 92 | 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)) |
86 | 96 | print('DONE')
|
0 commit comments