def udata(self): ud = [] for i in range(len(self.dat['names'])): udi = unique(self.dat['data'][i]) udi = udi[~udi.mask] # remove fill value from list ud.append(udi) return ud
def __uniquevals(self, d): u = ma.unique(d) u = u[~u.mask] return u
np.divide(dm0**2 + dm1**2 + dz0**2 + dz1**2, (m0 - m1 + z0 - z1)**2) + np.divide(dc0**2 + dc1**2, (1 - c0 + c1)**2) ) for row in group: colors.append(color) dcolors.append(dcolor) targets[filters] = np.array(colors) targets['d'+filters] = np.array(dcolors) # calibrate all the instrumental magnitudes zcol = [color_to_use[row['filter']][0] if color_to_use[row['filter']] else row['filter']*2 for row in targets] zeropoint = np.choose(zcol == targets['zcol1'], [targets['z2'], targets['z1']]) dzeropoint = np.choose(zcol == targets['zcol1'], [targets['dz2'], targets['dz1']]) colorterm = np.choose(zcol == targets['zcol1'], [targets['c2'], targets['c1']]) dcolorterm = np.choose(zcol == targets['zcol1'], [targets['dc2'], targets['dc1']]) uzcol, izcol = np.unique(zcol, return_inverse=True) color_used = np.choose(izcol, [targets[col].T if col in targets.colnames else 0. for col in uzcol]).filled(0.) # if no other filter, skip color correction dcolor_used = np.choose(izcol, [targets['d'+col].T if col in targets.colnames else 0. for col in uzcol]).filled(0.) targets['mag'] = (targets['instmag_amcorr'].T + zeropoint + colorterm * color_used).T targets['dmag'] = np.sqrt(targets['dinstmag'].T**2 + dzeropoint**2 + dcolorterm**2 * color_used**2 + colorterm**2 * dcolor_used**2).T if args.stage == 'mag': # write mag & dmag to database targets['dmag'].mask = targets['mag'].mask query = 'INSERT INTO photlco (filename, mag, dmag) VALUES\n' query += ',\n'.join(['("{}", {}, {})'.format(row['filename'], row['mag'], row['dmag']) for row in targets.filled(9999.)]) query += '\nON DUPLICATE KEY UPDATE mag=VALUES(mag), dmag=VALUES(dmag)' print query lsc.mysqldef.query([query], lsc.conn) elif args.stage == 'abscat': # write all the catalogs to files & put filename in database
# calibrate all the instrumental magnitudes zcol = [ color_to_use[row['filter']][0] if color_to_use[row['filter']] else row['filter'] * 2 for row in targets ] zeropoint = np.choose(zcol == targets['zcol1'], [targets['z2'], targets['z1']]) dzeropoint = np.choose(zcol == targets['zcol1'], [targets['dz2'], targets['dz1']]) colorterm = np.choose(zcol == targets['zcol1'], [targets['c2'], targets['c1']]) dcolorterm = np.choose(zcol == targets['zcol1'], [targets['dc2'], targets['dc1']]) uzcol, izcol = np.unique(zcol, return_inverse=True) color_used = np.choose( izcol, [targets[col].T if col in targets.colnames else 0. for col in uzcol]).filled( 0.) # if no other filter, skip color correction dcolor_used = np.choose(izcol, [ targets['d' + col].T if col in targets.colnames else 0. for col in uzcol ]).filled(0.) targets['mag'] = (targets['instmag_amcorr'].T + zeropoint + colorterm * color_used).T targets['dmag'] = np.sqrt(targets['dinstmag'].T**2 + dzeropoint**2 + dcolorterm**2 * color_used**2 + colorterm**2 * dcolor_used**2).T