def parser_args(default_args_file='args/default_tables.args'): """ Parse the command line args. With fromfile_pidxrefix_chars=@ we can read and parse command line args inside a file with @file.txt. default args inside default_args_file """ default_args = { 'output': 'dataframes.pkl', 'csv_dir': 'csv', } parser = readFileArgumentParser(fromfile_prefix_chars='@') parser.add_argument('--output', '-O', metavar='FILE', type=str, default=default_args['output']) parser.add_argument('--csv_dir', metavar='DIR', type=str, default=default_args['csv_dir']) parser.add_argument('--verbose', '-v', action='count') args_list = sys.argv[1:] # if exists file default.args, load default args if os.path.isfile(default_args_file): args_list.insert(0, '@%s' % default_args_file) debug_var(True, args_list=args_list) args = parser.parse_args(args=args_list) args = parser.parse_args(args=args_list) debug_var(True, args=args) return args
def plot_OH(ax, distance_HLR__r, OH__yx, OH_label, map__yx, cmap, OH_range, distance_range): x = np.ma.ravel(distance_HLR__yx) y = np.ma.ravel(OH__yx) ax.scatter(x, y, c=np.ravel(map__yx), cmap=cmap, **dflt_kw_scatter) ax.set_xlabel(r'R [HLR]') ax.set_ylabel(r'$12\ +\ \log$ (O/H) - %s [Z${}_\odot$]' % OH_label) ax.grid() ax.set_xlim(distance_range) ax.set_ylim(OH_range) debug_var(debug, OH_label=OH_label, MAX_OH__yx=OH__yx.max(), MIN_OH__yx=OH__yx.min()) return ax
def parser_args(default_args_file='default.args'): default_args = { 'debug': False, 'group': 'young', 'hdf5': 'output.h5', 'minpopx': np.finfo(np.float_).min, 'mintauv': np.finfo(np.float_).min, 'mintauvneb': np.finfo(np.float_).min, 'maxtauvneberr': np.finfo(np.float_).max, } parser = CustomArgumentParser(fromfile_prefix_chars='@') parser.add_argument('--debug', '-D', action='store_true', default=default_args['debug']) parser.add_argument('--hdf5', '-H', metavar='FILE', type=str, default=default_args['hdf5']) parser.add_argument('--pycasso_cube_dir', metavar='DIR', type=str, required=True) parser.add_argument('--eml_cube_dir', metavar='DIR', type=str, required=True) parser.add_argument('--gasprop_cube_dir', metavar='DIR', type=str, required=True) parser.add_argument('--minpopx', metavar='FRAC', type=float, help='Negative to disable mask in popx', default=default_args['minpopx']) parser.add_argument('--mintauv', metavar='FRAC', type=float, default=default_args['mintauv']) parser.add_argument('--mintauvneb', metavar='FRAC', type=float, default=default_args['mintauvneb']) parser.add_argument('--maxtauvneberr', metavar='FRAC', type=float, default=default_args['maxtauvneberr']) parser.add_argument('--group', metavar='GROUPNAME', type=str, default=default_args['group']) args_list = sys.argv[1:] # if exists file default.args, load default args if os.path.isfile(default_args_file): args_list.insert(0, '@%s' % default_args_file) debug_var(True, args_list=args_list) return fix_dir_args(parser.parse_args(args=args_list))
def parser_args(default_args_file='default.args'): ''' Parse the command line args With fromfile_prefix_chars=@ we can read and parse command line args inside a file with @file.txt. default args inside default_args_file ''' default_args = { 'debug': False, 'superfits': None, 'emlfits': None, 'rbinini': 0., 'rbinfin': 3., 'rbinstep': 0.2, 'sfth': 14, 'higth': 3, 'noflag': False, } parser = readFileArgumentParser(fromfile_prefix_chars='@') parser.add_argument('--debug', '-D', action='store_true', default=default_args['debug']) parser.add_argument('--superfits', '-S', metavar='FILE', type=str, default=default_args['superfits']) parser.add_argument('--emlfits', '-E', metavar='FILE', type=str, default=default_args['emlfits']) parser.add_argument('--sfth', metavar='FLOAT', type=float, default=default_args['sfth']) parser.add_argument('--higth', metavar='FLOAT', type=float, default=default_args['higth']) parser.add_argument('--rbinini', metavar='HLR', type=float, default=default_args['rbinini']) parser.add_argument('--rbinfin', metavar='HLR', type=float, default=default_args['rbinfin']) parser.add_argument('--rbinstep', metavar='HLR', type=float, default=default_args['rbinstep']) parser.add_argument('--noflag', '-F', action='store_true', default=default_args['noflag']) args_list = sys.argv[1:] # if exists file default.args, load default args print default_args_file if os.path.isfile(default_args_file): args_list.insert(0, '@%s' % default_args_file) debug_var(True, args_list=args_list) args = parser.parse_args(args=args_list) args.R_bin__r = np.arange(args.rbinini, args.rbinfin + args.rbinstep, args.rbinstep) args.R_bin_center__r = (args.R_bin__r[:-1] + args.R_bin__r[1:]) / 2.0 args.N_R_bins = len(args.R_bin_center__r) return args
def gather_needed_data(g, mto, mt, dump=True, output_filename='ALL_HaHb.pkl'): lines = [ '3727', '4363', '4861', '4959', '5007', '6300', '6563', '6583', '6717', '6731' ] keys2d = [ ('x_Y__Tz', N_T), ('SFR__Tz', N_T), ('SFRSD__Tz', N_T), ('integrated_x_Y__T', N_T), ] keys2d_masked = [('x_Y__Tyx', N_T), ('SFRSD__Tyx', N_T)] keys1d = [ 'Mini__z', 'Mcor__z', 'McorSD__z', 'tau_V__z', 'at_flux__z', 'at_mass__z', 'alogZ_flux__z', 'alogZ_mass__z', 'fobs_norm__z', 'zones_map', 'califaID__g', 'califaID__z', 'califaID__yx', 'pixels_map', 'x0', 'y0', 'N_x', 'N_y', 'N_zone', 'ml_ba', 'ba', 'pa', 'mt', 'mto', 'HLR_pix', 'HLR_pc', 'galDistance_Mpc', 'zoneArea_pc2', 'zoneArea_pix', 'redshift', 'pixelDistance__yx', 'pixelDistance_HLR__yx', 'zoneDistance_pc', 'zoneDistance_HLR', 'zoneDistance_pix', 'lines', 'CI', 'CI_9050', 'Mtot', 'qZones__yx', 'integrated_tau_V', 'integrated_tau_V_neb', 'integrated_etau_V_neb', 'integrated_alogZ_mass', 'integrated_at_flux', 'integrated_Dn4000', 'integrated_vd', 'integrated_v0', ] keys1d_masked = [ 'log_L6563_expected_HIG__z', 'log_L6563_expected_HIG__yx', 'at_flux__yx', 'at_mass__yx', 'alogZ_flux__yx', 'alogZ_mass__yx', 'fobs_norm__yx', 'tau_V__yx', 'tau_V_neb__z', 'etau_V_neb__z', 'tau_V_neb__yx', 'tau_V_neb_zeros__z', 'tau_V_neb_zeros__yx', 'qSn__z', 'qSn__yx', ] for l in lines: for prop in ['c', 'W', 'f', 'ef', 'SB', 'L']: prop_name = 'integrated_%s%s' % (prop, l) # print prop_name keys1d.append(prop_name) for bin in ['z', 'yx']: prop_name = '%s%s__%s' % (prop, l, bin) # print prop_name keys1d_masked.append(prop_name) # print keys1d # print keys1d_masked # sys.exit(1) ############################################################## ALL = stack_gals(keys1d=keys1d, keys1d_masked=keys1d_masked, keys2d=keys2d, keys2d_masked=keys2d_masked) # for i_gal, califaID in enumerate(g): # from pycasso import fitsQ3DataCube # K = fitsQ3DataCube('/Users/lacerda/califa/legacy/q057/superfits/px1Bgstf6e/%s_synthesis_eBR_px1_q057.d22a512.ps03.k1.mE.CCM.Bgstf6e.fits' % califaID) # # elliptical-geometry # K.setGeometry(*K.getEllipseParams()) for i_gal, K in loop_cubes(g, **kw_cube): califaID = g[i_gal] if K is None: print 'califaID:', califaID, ' trying another qVersion...' K = try_q055_instead_q054(califaID, **kw_cube) # if (K is None) or (K.EL is None): if K is None: # print 'califaID:%s missing fits files...' % califaID print 'SUPERFITS: %s : missing fits file.' % califaID continue # EMLDataCube_file = '/Users/lacerda/califa/legacy/q057/EML/px1Bgstf6e/%s_synthesis_eBR_px1_q057.d22a512.ps03.k1.mE.CCM.Bgstf6e.EML.MC100.fits' % califaID EMLDataCube_file = '%s/RGB/Bgstf6e/v04/%s_synthesis_eBR_v20_q054.d22a512.ps03.k1.mE.CCM.Bgstf6e.EML.MC100.fits' % ( os.getenv('HOME'), califaID) if os.path.isfile(EMLDataCube_file): K.loadEmLinesDataCube(EMLDataCube_file) else: print 'EML:', califaID, ' trying another qVersion...' # continue EMLDataCube_file = EMLDataCube_file.replace('q054', 'q055') if os.path.isfile(EMLDataCube_file): K.loadEmLinesDataCube(EMLDataCube_file) else: print 'EML: %s : missing fits file.' % califaID continue log_LHa_expected_HIG__z, log_LHa_expected_HIG__yx = calc_LHa_expected_HIG( K, [9.99e7, 1.00e20]) ALL.append1d_masked('log_L6563_expected_HIG__z', log_LHa_expected_HIG__z, np.ma.getmaskarray(log_LHa_expected_HIG__z)) ALL.append1d_masked( 'log_L6563_expected_HIG__yx', np.ravel(log_LHa_expected_HIG__yx), np.ravel(np.ma.getmaskarray(log_LHa_expected_HIG__yx))) ageBase = K.ageBase metBase = K.metBase # ALL.append1d_masked(k='qZones__yx', val=np.ravel(K.qZones), mask_val=K.qMask) ALL.append1d('qZones__yx', np.ravel(K.qZones)) ALL.append1d_masked(k='qSn__yx', val=np.ravel(K.qZonesSnOrig), mask_val=np.ravel( np.ma.getmaskarray(K.qZonesSnOrig))) qSn__z = get_zone_mean(K.qSn, K.qZones) ALL.append1d_masked(k='qSn__z', val=qSn__z, mask_val=np.zeros(K.N_zone, dtype='bool')) zones_map__z = np.array(list(range(K.N_zone)), dtype='int') ALL.append1d('zones_map', zones_map__z) califaID__z = np.array([K.califaID for i in range(K.N_zone)], dtype='|S5') ALL.append1d('califaID__z', califaID__z) califaID__yx = np.array([K.califaID for i in range(K.N_y * K.N_x)], dtype='|S5') ALL.append1d('califaID__yx', califaID__yx) pixels_map__yx = np.array(list(range(K.N_y * K.N_x)), dtype='int') # mto = get_morfologia(K.califaID)[0] ALL.append1d('redshift', K.redshift) ALL.append1d('califaID__g', califaID) ALL.append1d('mto', mto[i_gal]) ALL.append1d('mt', mt[i_gal]) ALL.append1d('pixels_map', pixels_map__yx) ALL.append1d('x0', K.x0) ALL.append1d('y0', K.y0) ALL.append1d('N_x', K.N_x) ALL.append1d('N_y', K.N_y) ALL.append1d('N_zone', K.N_zone) if 'ba' in K.masterListData.keys(): ALL.append1d('ml_ba', eval(K.masterListData['ba'])) elif 'gc_ba' in K.masterListData.keys(): if K.masterListData['gc_ba'] is None: ml_ba = -1 else: ml_ba = eval(K.masterListData['gc_ba']) ALL.append1d('ml_ba', ml_ba) ALL.append1d('ba', K.ba) ALL.append1d('pa', K.pa) ALL.append1d('HLR_pix', K.HLR_pix) ALL.append1d('HLR_pc', K.HLR_pc) ALL.append1d('galDistance_Mpc', K.distance_Mpc) ALL.append1d('zoneArea_pc2', K.zoneArea_pc2) ALL.append1d('zoneArea_pix', K.zoneArea_pix) ALL.append1d('pixelDistance__yx', np.ravel(K.pixelDistance__yx)) ALL.append1d('pixelDistance_HLR__yx', np.ravel(K.pixelDistance__yx / K.HLR_pix)) ALL.append1d('zoneDistance_pc', K.zoneDistance_pc) ALL.append1d('zoneDistance_HLR', K.zoneDistance_HLR) ALL.append1d('zoneDistance_pix', K.zoneDistance_pix) ALL.append1d('lines', lines) ALL.append1d('Mini__z', K.Mini__z) ALL.append1d('fobs_norm__z', K.fobs_norm) fobs_norm__yx = K.zoneToYX(K.fobs_norm / K.zoneArea_pix, extensive=False) ALL.append1d_masked('fobs_norm__yx', np.ravel(fobs_norm__yx), np.ravel(np.ma.getmaskarray(fobs_norm__yx))) ALL.append1d('Mtot', K.Mcor_tot.sum()) ALL.append1d('Mcor__z', K.Mcor__z) ALL.append1d('McorSD__z', K.Mcor__z / K.zoneArea_pc2) ALL.append1d('at_flux__z', K.at_flux__z) ALL.append1d_masked('at_flux__yx', np.ravel(K.at_flux__yx), np.ravel(np.ma.getmaskarray(K.at_flux__yx))) ALL.append1d('at_mass__z', K.at_mass__z) ALL.append1d_masked('at_mass__yx', np.ravel(K.at_mass__yx), np.ravel(np.ma.getmaskarray(K.at_mass__yx))) ALL.append1d('tau_V__z', K.tau_V__z) ALL.append1d('integrated_tau_V', K.integrated_tau_V) ALL.append1d('alogZ_flux__z', K.alogZ_flux__z) ALL.append1d_masked('alogZ_flux__yx', np.ravel(K.alogZ_flux__yx), np.ravel(np.ma.getmaskarray(K.alogZ_flux__yx))) ALL.append1d('alogZ_mass__z', K.alogZ_mass__z) ALL.append1d_masked('alogZ_mass__yx', np.ravel(K.alogZ_mass__yx), np.ravel(np.ma.getmaskarray(K.alogZ_mass__yx))) ALL.append1d('integrated_alogZ_mass', K.integrated_alogZ_mass) ALL.append1d('integrated_at_flux', K.integrated_at_flux) ALL.append1d('integrated_Dn4000', K.integrated_Dn4000) ALL.append1d('integrated_vd', K.integrated_keywords['V_D']) ALL.append1d('integrated_v0', K.integrated_keywords['V_0']) ######################## # tSF things for iT, tSF in enumerate(tSF__T): x_Y__z, integrated_x_Y = calc_xY(K, tSF) x_Y__yx, _ = calc_xY(tY=tSF, ageBase=K.ageBase, popx=K.popx__tZyx) ALL.append2d(k='x_Y__Tz', i=iT, val=x_Y__z) ALL.append2d_masked(k='x_Y__Tyx', i=iT, val=np.ravel(x_Y__yx), mask_val=np.ravel(np.ma.getmaskarray(x_Y__yx))) ALL.append2d(k='integrated_x_Y__T', i=iT, val=integrated_x_Y) SFR__z, SFRSD__z = calc_SFR(K, tSF) SFRSD__yx = prop_Y(K.MiniSD__tZyx, tSF, K.ageBase) / tSF ALL.append2d(k='SFR__Tz', i=iT, val=SFR__z) ALL.append2d(k='SFRSD__Tz', i=iT, val=SFRSD__z) ALL.append2d_masked(k='SFRSD__Tyx', i=iT, val=np.ravel(SFRSD__yx), mask_val=np.ravel( np.ma.getmaskarray(SFRSD__yx))) ######################## ''' CI: Calc. usando a equacao que ta no paper do Conselice - http://iopscience.iop.org/article/10.1086/375001/pdf, pagina 7 - e r80 e r20 calculando usando o lambda de normalizacao do CALIFA, ou seja, da mesma forma que o HLR (r50) e calculado mas utilizando 0.8 e 0.2 como fracao ao inves de 0.5 (half). ''' r90 = getGenFracRadius(K.qSignal[K.qMask], K.pixelDistance__yx[K.qMask], None, frac=0.9) r80 = getGenFracRadius(K.qSignal[K.qMask], K.pixelDistance__yx[K.qMask], None, frac=0.8) r50 = getGenFracRadius(K.qSignal[K.qMask], K.pixelDistance__yx[K.qMask], None, frac=0.5) r20 = getGenFracRadius(K.qSignal[K.qMask], K.pixelDistance__yx[K.qMask], None, frac=0.2) CI = 5. * np.log10(r80 / r20) CI_9050 = 5. * np.log10(r90 / r50) ALL.append1d('CI', CI) ALL.append1d('CI_9050', CI_9050) debug_var(debug, CALIFAID=califaID, CI=CI, CI_9050=CI_9050) tau_V__yx = K.A_V__yx / (2.5 * np.log10(np.exp(1.))) ALL.append1d_masked(k='tau_V__yx', val=np.ravel(tau_V__yx), mask_val=np.ravel(np.ma.getmaskarray(tau_V__yx))) # EML ALL.append1d_masked(k='tau_V_neb__z', val=K.EL.tau_V_neb__z.data, mask_val=np.ma.getmaskarray(K.EL.tau_V_neb__z)) tau_V_neb_zeros__z = np.where((K.EL.tau_V_neb__z < 0).filled(True), 0, K.EL.tau_V_neb__z) ALL.append1d_masked(k='tau_V_neb_zeros__z', val=tau_V_neb_zeros__z, mask_val=np.zeros((K.N_zone), dtype='bool')) etau_V_neb__z = K.EL.tau_V_neb_err__z ALL.append1d_masked(k='etau_V_neb__z', val=etau_V_neb__z, mask_val=np.ma.getmaskarray(K.EL.tau_V_neb_err__z)) tau_V_neb__yx = K.zoneToYX(K.EL.tau_V_neb__z, extensive=False) ALL.append1d_masked(k='tau_V_neb__yx', val=np.ravel(tau_V_neb__yx), mask_val=np.ravel( np.ma.getmaskarray(tau_V_neb__yx))) tau_V_neb__yx = K.zoneToYX(tau_V_neb_zeros__z, extensive=False) ALL.append1d_masked(k='tau_V_neb_zeros__yx', val=np.ravel(tau_V_neb__yx), mask_val=np.ravel( np.ma.getmaskarray(tau_V_neb__yx))) ALL.append1d('integrated_tau_V_neb', K.EL.integrated_tau_V_neb) ALL.append1d('integrated_etau_V_neb', K.EL.integrated_tau_V_neb_err) ######################## for l in lines: if l not in K.EL.lines: zeros__z = np.ma.masked_all((K.N_zone)) zeros__yx = np.ma.masked_all((K.N_y * K.N_x)) ALL.append1d_masked('f%s__z' % l, zeros__z, np.ma.getmaskarray(zeros__z)) ALL.append1d_masked('ef%s__z' % l, zeros__z, np.ma.getmaskarray(zeros__z)) ALL.append1d_masked('SB%s__z' % l, zeros__z, np.ma.getmaskarray(zeros__z)) ALL.append1d_masked('L%s__z' % l, zeros__z, np.ma.getmaskarray(zeros__z)) ALL.append1d_masked('W%s__z' % l, zeros__z, np.ma.getmaskarray(zeros__z)) ALL.append1d_masked('c%s__z' % l, zeros__z, np.ma.getmaskarray(zeros__z)) ALL.append1d_masked('f%s__yx' % l, zeros__yx, np.ma.getmaskarray(zeros__yx)) ALL.append1d_masked('ef%s__yx' % l, zeros__yx, np.ma.getmaskarray(zeros__yx)) ALL.append1d_masked('SB%s__yx' % l, zeros__yx, np.ma.getmaskarray(zeros__yx)) ALL.append1d_masked('L%s__yx' % l, zeros__yx, np.ma.getmaskarray(zeros__yx)) ALL.append1d_masked('W%s__yx' % l, zeros__yx, np.ma.getmaskarray(zeros__yx)) ALL.append1d_masked('c%s__yx' % l, zeros__yx, np.ma.getmaskarray(zeros__yx)) ALL.append1d('integrated_f%s' % l, 0.) ALL.append1d('integrated_ef%s' % l, 0.) ALL.append1d('integrated_L%s' % l, 0.) ALL.append1d('integrated_SB%s' % l, 0.) ALL.append1d('integrated_W%s' % l, 0.) ALL.append1d('integrated_c%s' % l, 0.) else: i = K.EL.lines.index(l) mask = np.bitwise_or(~np.isfinite(K.EL.flux[i]), np.less(K.EL.flux[i], 1e-40)) fl_obs__z = np.ma.masked_array(K.EL.flux[i], mask=mask, copy=True) ALL.append1d_masked('f%s__z' % l, fl_obs__z, mask) efl_obs__z = np.ma.masked_array(K.EL.eflux[i], mask=mask, copy=True) ALL.append1d_masked('ef%s__z' % l, efl_obs__z, mask) Ll_obs__z = K.EL._F_to_L(fl_obs__z) / L_sun integrated_Ll_obs = K.EL._F_to_L( K.EL.integrated_flux[i]) / L_sun ALL.append1d_masked('L%s__z' % l, Ll_obs__z, np.ma.getmaskarray(Ll_obs__z)) SBl_obs__z = Ll_obs__z / (K.zoneArea_pc2 * 1e-6) integrated_SBl_obs = integrated_Ll_obs / ( K.zoneArea_pc2.sum() * 1e-6) ALL.append1d_masked('SB%s__z' % l, SBl_obs__z, np.ma.getmaskarray(SBl_obs__z)) W__z = K.EL.EW[i] integrated_W = K.EL.integrated_EW[i] ALL.append1d_masked('W%s__z' % l, W__z, np.ma.getmaskarray(W__z)) c__z = K.EL.baseline[i] integrated_c = K.EL.integrated_baseline[i] ALL.append1d_masked('c%s__z' % l, c__z, np.ma.getmaskarray(c__z)) fl_obs__yx = K.zoneToYX(fl_obs__z / K.zoneArea_pix, extensive=False) ALL.append1d_masked('f%s__yx' % l, np.ravel(fl_obs__yx), np.ravel(np.ma.getmaskarray(fl_obs__yx))) efl_obs__yx = K.zoneToYX(efl_obs__z / K.zoneArea_pix, extensive=False) ALL.append1d_masked('ef%s__yx' % l, np.ravel(efl_obs__yx), np.ravel(np.ma.getmaskarray(efl_obs__yx))) Ll_obs__yx = K.EL._F_to_L(fl_obs__yx) / L_sun ALL.append1d_masked('L%s__yx' % l, np.ravel(Ll_obs__yx), np.ravel(np.ma.getmaskarray(Ll_obs__yx))) SBl_obs__yx = K.zoneToYX(Ll_obs__z / (K.zoneArea_pc2 * 1e-6), extensive=False) ALL.append1d_masked('SB%s__yx' % l, np.ravel(SBl_obs__yx), np.ravel(np.ma.getmaskarray(SBl_obs__yx))) W__yx = K.zoneToYX(W__z, extensive=False) ALL.append1d_masked('W%s__yx' % l, np.ravel(W__yx), np.ravel(np.ma.getmaskarray(W__yx))) c__yx = K.zoneToYX(c__z / K.zoneArea_pix, extensive=False) ALL.append1d_masked('c%s__yx' % l, np.ravel(c__yx), np.ravel(np.ma.getmaskarray(c__yx))) ALL.append1d('integrated_f%s' % l, K.EL.integrated_flux[i]) ALL.append1d('integrated_ef%s' % l, K.EL.integrated_eflux[i]) ALL.append1d('integrated_L%s' % l, integrated_Ll_obs) ALL.append1d('integrated_SB%s' % l, integrated_SBl_obs) ALL.append1d('integrated_W%s' % l, integrated_W) ALL.append1d('integrated_c%s' % l, integrated_c) ######################## ALL.stack() ALL.ageBase = ageBase ALL.metBase = metBase ALL.tSF__T = tSF__T ALL.N_T = N_T if dump: ALL.dump(output_filename) return ALL
SFR__z = (aux1__z + aux2__z) / tSF SFRSD__z = SFR__z / K.zoneArea_pc2 # aux1__z = K.MiniSD__tZz[:indSF, :, :].sum(axis=1).sum(axis=0) # aux2__z = K.MiniSD__tZz[indSF, :, :].sum(axis=0) * (tSF - aLow__t[indSF]) / (aUpp__t[indSF] - aLow__t[indSF]) return SFR__z, SFRSD__z if __name__ == '__main__': # Saving the initial time t_init_prog = time.clock() # Parse arguments args = parser_args(default_args_file='SFR_default.args') debug_var(True, args=args.__dict__) tSF__T = np.array([1, 3.2, 10, 50, 100]) * 1e7 N_T = len(tSF__T) q = redenninglaws.Cardelli_RedLaw([4861, 5007, 6563, 6583]) h5file = tbl.open_file(args.hdf5, mode='r+') tbl_gals = h5file.root.pycasso.main tbl_zones = h5file.root.pycasso.zones tbl_integrated = h5file.root.pycasso.integrated group_description = 'minpopx:%.2f' % args.minpopx group_description += '/mintauV:%.2f' % args.mintauv group_description += '/mintauVneb:%.2f/' % args.mintauvneb group_description += 'maxtauVneberr:%.2f' % args.maxtauvneberr
def parser_args(default_args_file='args/default_selection.args'): """ Parse the command line args. With fromfile_pidxrefix_chars=@ we can read and parse command line args inside a file with @file.txt. default args inside default_args_file """ default_args = { 'input': 'dataframes.pkl', 'output': 'elines_clean.pkl', 'broad_fit_rules': False, 'no_sigma_clip': False, 'print_color': False, 'csv_dir': 'csv', 'bug': 0.8, 'output_agn_candidates': 'AGN_CANDIDATES.csv', 'EW_SF': 10., 'EW_AGN': 3., 'EW_hDIG': 3., 'EW_strong': 6., 'EW_verystrong': 10., 'min_SN_broad': 8., 'only_report': False, 'zmax': 5, 'zmin': 0, } parser = readFileArgumentParser(fromfile_prefix_chars='@') parser.add_argument('--input', '-I', metavar='FILE', type=str, default=default_args['input']) parser.add_argument('--output', '-O', metavar='FILE', type=str, default=default_args['output']) parser.add_argument('--broad_fit_rules', '-B', action='store_true', default=default_args['broad_fit_rules']) parser.add_argument('--only_report', '-R', action='store_true', default=default_args['only_report']) parser.add_argument('--print_color', action='store_true', default=default_args['print_color']) parser.add_argument('--no_sigma_clip', action='store_true', default=default_args['no_sigma_clip']) parser.add_argument('--csv_dir', metavar='DIR', type=str, default=default_args['csv_dir']) parser.add_argument('--output_agn_candidates', metavar='FILE', type=str, default=default_args['output_agn_candidates']) parser.add_argument('--verbose', '-v', action='count') parser.add_argument('--zmin', metavar='FLOAT', type=float, default=default_args['zmin']) parser.add_argument('--zmax', metavar='FLOAT', type=float, default=default_args['zmax']) parser.add_argument('--EW_SF', metavar='FLOAT', type=float, default=default_args['EW_SF']) parser.add_argument('--EW_AGN', metavar='FLOAT', type=float, default=default_args['EW_AGN']) parser.add_argument('--EW_hDIG', metavar='FLOAT', type=float, default=default_args['EW_hDIG']) parser.add_argument('--EW_strong', metavar='FLOAT', type=float, default=default_args['EW_strong']) parser.add_argument('--EW_verystrong', metavar='FLOAT', type=float, default=default_args['EW_verystrong']) parser.add_argument('--min_SN_broad', metavar='FLOAT', type=float, default=default_args['min_SN_broad']) parser.add_argument('--bug', metavar='FLOAT', type=float, default=default_args['bug']) args_list = sys.argv[1:] # if exists file default.args, load default args if os.path.isfile(default_args_file): args_list.insert(0, '@%s' % default_args_file) debug_var(True, args_list=args_list) args = parser.parse_args(args=args_list) args = parser.parse_args(args=args_list) debug_var(True, args=args) return args