def handleResults(f, results2): count = 0 temper = results2["teff_val"] print("Min K: {0} - Max K: {1}".format(min(temper), max(temper))) dist = coord.Distance(parallax=u.Quantity(results2["parallax"])) print("Min Parallax: {0} - Max Parallax: {1}".format(min(dist), max(dist))) print(len(results2)) for row in results2: dist = coord.Distance(parallax=u.Quantity(row["parallax"] * u.mas)) c = coord.SkyCoord(ra=row["ra"] * u.deg, dec=row["dec"] * u.deg, distance=dist) c = c.cartesian radius = float(row["radius_val"]) if math.isnan(radius): radius = float(0) source_id = np.longlong(row["source_id"]) print(c.x.value / 26000.0) print(c.y.value / 26000.0) print(c.z.value / 26000.0) x = np.single(c.x.value) y = np.single(c.y.value) z = np.single(c.z.value) global maxX global maxY global maxZ if abs(x) > maxX: maxX = abs(x) if abs(y) > maxY: maxY = abs(y) if abs(z) > maxZ: maxZ = abs(z) temper = math.floor(row["teff_val"]) appendToFile(f, x, y, z, temper, float(dist.value), radius, source_id) count = count + 1 sys.stdout.write("\rFortschritt: " + str(count) + "/" + str(maxSelection)) global maxValue global queriedStars queriedStars = queriedStars + count maxValue = max(maxX, maxY, maxZ)
def getGAIAKnownMembers(name_mapper=None): """ returns known member list from Gaia paper: http://simbad.u-strasbg.fr/simbad/sim-ref?bibcode=2018A%26A...616A..10G (Table1a: Nearby Open Clusters) Returns: Pandas dataframe indexed by SourceID, and list of cluster names retrieved. """ known_members = pd.read_csv('ftp://cdsarc.u-strasbg.fr/pub/cats/J/A+A/616/A10/tablea1a.dat', delim_whitespace=True, header=None, index_col=None, names = ['SourceID', 'Cluster', 'RAdeg', 'DEdeg', 'Gmag', 'plx', 'e_plx']) known_members.set_index('SourceID', inplace=True) cluster_names = known_members.Cluster.unique() #not sure how to deal with name mapping back to SIMBAD names #name_mapper = {'Pleiades': 'Pleiades'} #members['SimbadCluster'] = members.Cluster.apply(lambda c:name_mapper[c]) #make skycoords objects for each member, using gaia epoch of 2015.5 known_members['coords']=SkyCoord(ra = np.array(known_members.RAdeg)*u.degree, dec = np.array(known_members.DEdeg)*u.degree, obstime = Time(2015.5,format='decimalyear'), #Gaia ref epoch is 2015.5 distance = coord.Distance(parallax=Quantity(np.array(known_members.plx)*u.mas))) return(known_members, cluster_names)
def plot_hrdiagram(self, **kwargs): ax = kwargs.get('ax') title = kwargs.get('title') color = kwargs.get('color') if color is None: color = 'blue' if ax is not None: yax = ax else: yax = plt.subplot(111) #distmod = 5*np.log10(self.objs.rest)-5 distance = coord.Distance(parallax=u.Quantity( np.array(self.objs.Plx) * u.mas), allow_negative=True) abs_mag = self.objs.Gmag - distance.distmod.value BP_RP = self.objs.BPmag - self.objs.RPmag yax.scatter(BP_RP, abs_mag, s=1, label=self.cluster_name, color=color) if not yax.yaxis_inverted(): yax.invert_yaxis() yax.set_xlim(-1, 5) #yax.set_ylim(20, -1) yax.set_title(title) if ax is None: yax.legend()
def get_distance(self, min_parallax=None, parallax_fill_value=np.nan, allow_negative=False): """Compute distance from parallax (by inverting the parallax) using `~astropy.coordinates.Distance`. Parameters ---------- min_parallax : `~astropy.units.Quantity` (optional) If `min_parallax` specified, the parallaxes are clipped to this values (and it is also used to replace NaNs). allow_negative : bool (optional) This is passed through to `~astropy.coordinates.Distance`. Returns ------- dist : `~astropy.coordinates.Distance` A ``Distance`` object with the data. """ plx = self.parallax.copy() if np.isnan(parallax_fill_value): parallax_fill_value = parallax_fill_value * u.mas if min_parallax is not None: clipped = plx < min_parallax clipped |= ~np.isfinite(plx) plx[clipped] = parallax_fill_value return coord.Distance(parallax=plx, allow_negative=allow_negative)
def getVs(df): """ Calculates tangential velocity (v_tan) and vertical velocity proximation (v_b). Args: df ([Pandas DataFrame]): DataFrame contains columns 'parallax', 'pmra', 'pmdec', 'ra', 'dec', which are parallax, ra proper motion, dec propermotion, right ascension and declination, respectively Returns: :v_t ([array-like]): Tangential velocity :v_b ([array-like]): Proxy for vertical velocity """ d = coord.Distance(parallax=np.array(df.parallax) * u.mas, allow_negative=True) vra = (np.array(df.pmra) * u.mas / u.yr * d).to(u.km / u.s, u.dimensionless_angles()) vdec = (np.array(df.pmdec) * u.mas / u.yr * d).to(u.km / u.s, u.dimensionless_angles()) v_t = np.sqrt(np.power(vra, 2.) + np.power(vdec, 2.)) # vtan # v_b as a proxy for v_z: c = coord.SkyCoord(ra=np.array(df.ra) * u.deg, dec=np.array(df.dec) * u.deg, distance=d, pm_ra_cosdec=np.array(df.pmra) * u.mas / u.yr, pm_dec=np.array(df.pmdec) * u.mas / u.yr) gal = c.galactic v_b = (gal.pm_b * gal.distance).to(u.km / u.s, u.dimensionless_angles()) # vb return v_t, v_b
def get_norm_model(self, phase, distance): """ Get the flam spectrum for some specific phase and distance """ dist = c.Distance(distance * u.megaparsec) z = dist.z lam, flam = self.get_model(phase) lamz = lam * (1. + z) fnorm = flam / (4 * np.pi * (distance * MPC_TO_CM)**2.) return lamz, fnorm
def starCat(star): """ Catalog of stellar coordinates Input: star: string name of star Output: SkyCoord object with icrs coords """ # RA-hours, RA-min, RA-sec, dec-sign, dec-deg, dec-amin, dec-asec sCat = { 'Algol': [3., 8., 10.132, 1., 40., 57., 20.33],\ 'V0738+2950': [7., 38., 37.363, +1., 29., 50., 31.42],\ 'V859 Cyg': [19., 27., 13., 1., 28., 56., 50.],\ 'KIC 02305372': [19.,27.,57.7,1.,37.,40.,22.1],\ 'KIC 03104113': [19.,12.,9.5,1.,38.,17.,38.8],\ 'KIC 03765708': [19.,43.,42.7,1.,38.,50.,55.7],\ 'KIC 04074532': [19.,43.,4.9,1.,39.,6.,36.0],\ 'KIC 04851217': [19.,43.,20.2,1.,39.,57.,8.3],\ 'KIC 05020034': [19.,37.,12.9,1.,40.,11.,33.4],\ 'KIC 05770860': [18.,56.,45.6,1.,41.,1.,30.0],\ 'KIC 06044064': [19.,29.,24.8,1.,41.,19.,27.1],\ 'KIC 06213131': [19.,37.,12.9,1.,41.,33.,42.1],\ 'KIC 06464285': [19.,50.,41.0,1.,41.,52.,33.6],\ 'KIC 06677225': [19.,8.,33.0,1.,42.,8.,40.2],\ 'KIC 07696778': [19.,45.,9.1,1.,43.,23.,55.3],\ 'KIC 07938468': [18.,47.,46.4,1.,43.,43.,43.0],\ 'KIC 09087918': [19.,25.,56.1,1.,45.,25.,1.9],\ 'KIC 09934052': [18.,49.,43.3,1.,46.,48.,25.6],\ 'KIC 10030943': [19.,54.,12.4,1.,46.,56.,12.5],\ 'KIC 10736223': [19.,35.,23.1,1.,48.,3.,1.1],\ 'KIC 11097678': [19.,50.,28.7,1.,48.,41.,36.6],\ 'KIC 11144556': [19.,40.,28.6,1.,48.,43.,58.4],\ 'KIC 11924311': [19.,46.,39.8,1.,50.,14.,17.9],\ 'KIC 04853067': [19.,44.,53.1,1.,39.,55.,22.8],\ 'KIC 05471619': [19.,50.,48.9,1.,40.,38.,33.0],\ 'KIC 05792093': [19.,28.,48.0,1.,41.,0.,49.3],\ 'KIC 06044543': [19.,29.,56.4,1.,41.,18.,56.2],\ 'KIC 06066379': [19.,52.,31.8,1.,41.,20.,3.5],\ 'KIC 06314173': [19.,56.,57.7,1.,41.,37.,18.1],\ 'KIC 07938870': [18.,48.,44.0,1.,43.,42.,23.0],\ 'KIC 09402652': [19.,25.,6.9,1.,45.,56.,3.1],\ 'KIC 09840412': [19.,42.,10.5,1.,46.,37.,10.6],\ 'KIC 10292413': [19.,52.,29.6,1.,47.,19.,30.4],\ 'KIC 08758161': [19.,34.,28.9,1.,44.,58.,2.3],\ 'KIC 09832227': [19.,29.,16.0,1.,46.,37.,19.9],\ 'KIC 9832227': [19., 29., 15.95, 1., 46., 37., 19.88],\ 'BL Lac': [22., 02., 43.2, +1., 42., 16., 40.],\ 'Y Sex': [10., 02., 48.0, +1., 01., 05., 40.],\ 'E11': [05., 04., 48.8, +1., 53., 00., 18.],\ 'A22': [05., 14., 09.4, +1., 58., 25., 53.],\ 'A34': [05., 16., 02.5, +1., 58., 52., 50.],\ 'Test': [15., 0., 0., -1., 71., 0., 0.] } x = sCat[star] ra = (x[0] + x[1] / 60. + x[2] / 3600.) * (360. / 24.) dec = x[3] * (x[4] + x[5] / 60. + x[6] / 3600.) src_vec = coords.SkyCoord(ra=ra * u.degree, dec=dec * u.degree, frame='icrs', distance=coords.Distance(1, u.km)) return src_vec
def starCoords(star, ra, dec): """ Catalog of stellar coordinates Input: star: string name of star ra: ra (deg) dec: dec (deg) Output: SkyCoord object with icrs coords """ src_vec = coords.SkyCoord(ra=ra * u.degree, dec=dec * u.degree, frame='icrs', distance=coords.Distance(1, u.km)) return src_vec
def calc_luminosity(redshift, flux_density, wl): """ Takes a redshift and flux density and returns an approximate luminosity. Supperceded by HELMS_Wrapper stuff """ distance = c.Distance(z=redshift) distance = distance.value distance = distance * 3.086 * 10**19 flux = flux_density * 3.631 * (10**-32) * wl lum = 4 * np.pi * flux * (distance**2) return lum
def oph(): data = ascii.read('../data/sesar.txt', format='commented_header', header_start=2) c = coord.SkyCoord(ra=data['ra'] * u.deg, dec=data['dec'] * u.deg, distance=coord.Distance(distmod=data['DM'])) galcen = c.transform_to(gc_frame) xyz = galcen.data.xyz.T.value.tolist() return {'color': oph_color, 'data': xyz, 'opacity': 0.8}
def CalcV(df): d = coord.Distance(parallax=np.array(df.parallax) * u.mas,allow_negative=True) vra = (np.array(df.pmra)*u.mas/u.yr * d).to(u.km/u.s, u.dimensionless_angles()) vdec = (np.array(df.pmdec)*u.mas/u.yr * d).to(u.km/u.s, u.dimensionless_angles()) v_t=np.sqrt(np.power(vra,2.)+np.power(vdec,2.)) # vtan # v_b as a proxy for v_z: c = coord.SkyCoord(ra=np.array(df.ra)*u.deg, dec=np.array(df.dec)*u.deg, distance=d, pm_ra_cosdec=np.array(df.pmra)*u.mas/u.yr, pm_dec=np.array(df.pmdec)*u.mas/u.yr) gal = c.galactic v_b = (gal.pm_b * gal.distance).to(u.km/u.s, u.dimensionless_angles()) # vb return v_t,v_b
def formatSIMBADtoGAIA(simbad_table, name_mapper=None): """ the simbad table has different collumn names and coordinates than GAIA, this function converts the SIMBAD data table into the GAIA format """ if name_mapper is not None: if not isinstance(name_mapper, dict): raise TypeError('name_mapper argurment must be a dict') my_table = simbad_table.copy() # so we don't clobber the argument table #change the TYPED_ID to a regular ol' string (gotta be a better way to do this): my_table['TYPED_ID'] = [c.decode('utf-8') for c in my_table['TYPED_ID']] #fix up the column names my_table.rename_column('TYPED_ID','typed_id') my_table.rename_column('PLX_VALUE','parallax') my_table.rename_column('PLX_PREC', 'parallax_error') my_table.rename_column('RA', 'ra') my_table.rename_column('RA_PREC','ra_error') my_table.rename_column('DEC', 'dec') my_table.rename_column('DEC_PREC','dec_error') my_table.rename_column('PMRA', 'pmra') my_table.rename_column('PMDEC', 'pmdec') my_table.rename_column('RVZ_RADVEL','radial_velocity') my_table.rename_column('RVZ_ERROR', 'rv_error') #ditch the masked arrays my_table = my_table.filled() #add cluster column which is either the typed name or the mapped name if name_mapper is not None: #for names not mapped, substitute the typed_id my_table['cluster']=[name_mapper.get(tid, tid) for tid in my_table['typed_id']] else: my_table['cluster'] = my_table['typed_id'] #add index on cluster my_table.add_index('cluster') #tack on sky coordinate objects for each my_table['coords'] = \ SkyCoord(ra = my_table['ra'], dec = my_table['dec'], unit = (u.hour, u.deg), obstime = 'J2000', #simbad returns J2000 coords distance = coord.Distance(parallax=Quantity(my_table['parallax'])), pm_ra_cosdec = my_table['pmra'], #SIMBAD labels it pmra but the measure includes cos(dec) pm_dec = my_table['pmdec'], radial_velocity = my_table['radial_velocity']).apply_space_motion(new_obstime=Time(2015.5,format='decimalyear')) return(my_table)
def get_distance(self, lutz_kelker=False): """Return the distance with or without the Lutz-Kelker correction. Parameters ---------- lutz_kelker : bool, optional Apply the Lutz-Kelker correction to the distance. You probably don't want to do this. """ if lutz_kelker: snr = self.parallax / self.parallax_error tmp = self.parallax * (0.5 + 0.5 * np.sqrt(1 - 16 / snr**2)) else: tmp = self.parallax return coord.Distance(tmp.to(u.pc, u.parallax()))
def get_distance(self, min_parallax=None, allow_negative=False): """ Compute distance from parallax using `~astropy.coordinates.Distance`. If `min_parallax` supplied, then the parallaxes are clipped to this values (and it is also used to replace NaNs). `allow_negative` is passed through to `~astropy.coordinates.Distance`. """ plx = self.parallax.copy() if min_parallax is not None: clipped = plx < min_parallax.to(plx.unit, u.parallax()) clipped |= ~np.isfinite(plx) plx[clipped] = min_parallax.to(plx.unit, u.parallax()) return coord.Distance(parallax=plx, allow_negative=allow_negative)
def calc_vb(mean_list): """ Calculate latitudinal velocity. Args: mean_list (list): list of arrays of, ra: Right Ascension in degrees. dec: Declination in degrees. parallax: parallax in milliarcseconds. pmra: RA proper motion in milliarcseconds per year. pmdec: Dec proper motion in milliarcseconds per year. Returns: The array of latitudinal velocities. """ ra, dec, parallax, pmra, pmdec = mean_list # icrs = ICRS(ra=ra*u.degree, # dec=dec*u.degree, # distance=distance*u.pc, # pm_ra_cosdec=pmra*u.mas/u.yr, # pm_dec=pmdec*u.mas/u.yr) # vels = icrs.transform_to(Galactic) d = coord.Distance(parallax=parallax * u.mas) vra = (pmra * u.mas / u.yr * d).to(u.km / u.s, u.dimensionless_angles()) vdec = (pmdec * u.mas / u.yr * d).to(u.km / u.s, u.dimensionless_angles()) c = coord.SkyCoord(ra=ra * u.deg, dec=dec * u.deg, distance=d, pm_ra_cosdec=pmra * u.mas / u.yr, pm_dec=pmdec * u.mas / u.yr) gal = c.galactic v_b = (gal.pm_b * gal.distance).to(u.km / u.s, u.dimensionless_angles()) return v_b
def get_lum(flux_density, redshift, band=250): """ Returns the wavelength specific luminosity given its flux density. Returns luminosity in watts. flux_density: float The flux density of the object at the given wavelength. Assumed to be in Jy (HELMS survey is in Jy) redshift: float The redshift of the object band: int The wavelength of the flux density. In micrometres. """ if not band in [250, 350, 500]: raise ValueError("Band must be 250, 350 of 500 microns!") freq = const.c / (band * 10**-6) d = c.Distance(z=redshift) distance = d.value flux = flux_density * freq lum = 4 * np.pi * flux * (distance**2) return lum.value
axes[1, 2].set_xlabel('RV'); pp.savefig(bbox_inches='tight') pp.close() assert np.all(sample[:, 2] > 0) # Calculate dynamics print('Get dynamics') R0 = 8.34 * u.kpc # Reid et al 2014 V0 = 240 * u.km/u.s # Reid et al 2014 z_sun = 27 * u.pc # Chen et al 2001 v_sun = coord.CartesianDifferential([11.1, -(240+12.24), 7.25] * u.km/u.s) # Schonrich et al 2010 # NB: Here I just use the inverse parallax as dist cs = coord.SkyCoord(ra=sample[:, 0] * u.deg, dec=sample[:, 1] * u.deg, distance=coord.Distance(parallax=sample[:, 2] * u.mas), pm_ra_cosdec=sample[:, 3] * u.mas / u.yr, pm_dec=sample[:, 4] * u.mas / u.yr, radial_velocity=sample[:, 5] * u.km / u.s, galcen_distance=R0, galcen_v_sun=v_sun, z_sun=z_sun) # Define Galactocentric frame gc = coord.Galactocentric(galcen_distance=R0, galcen_v_sun=v_sun, # 240 is from Reid etal 2014 z_sun=z_sun) # Default, Chen et al 2001 cs = cs.transform_to(gc) cs.representation_type = 'cylindrical' cs.differential_type = 'cylindrical'
# These classes inherit from a common base class and internally contain Quantity # objects, which are arrays (although they may act as scalars, like numpy's # length-0 "arrays") # They can be initialized with a variety of ways that make intuitive sense. # Distance is optional. coords.SphericalRepresentation(lon=8*u.hour, lat=5*u.deg) coords.SphericalRepresentation(lon=8*u.hourangle, lat=5*u.deg) coords.SphericalRepresentation(lon=8*u.hourangle, lat=5*u.deg, distance=10*u.kpc) # In the initial implementation, the lat/lon/distance arguments to the # initializer must be in order. A *possible* future change will be to allow # smarter guessing of the order. E.g. `Latitude` and `Longitude` objects can be # given in any order. coords.SphericalRepresentation(coords.Longitude(8, u.hour), coords.Latitude(5, u.deg)) coords.SphericalRepresentation(coords.Longitude(8, u.hour), coords.Latitude(5, u.deg), coords.Distance(10, u.kpc)) # Arrays of any of the inputs are fine coords.SphericalRepresentation(lon=[8, 9]*u.hourangle, lat=[5, 6]*u.deg) # Default is to copy arrays, but optionally, it can be a reference coords.SphericalRepresentation(lon=[8, 9]*u.hourangle, lat=[5, 6]*u.deg, copy=False) # strings are parsed by `Latitude` and `Longitude` constructors, so no need to # implement parsing in the Representation classes coords.SphericalRepresentation(lon='2h6m3.3s', lat='5rad') # Or, you can give `Quantity`s with keywords, and they will be internally # converted to Angle/Distance c1 = coords.SphericalRepresentation(lon=8*u.hourangle, lat=5*u.deg, distance=10*u.kpc)
(0.0, 42, 44.299999999999784) Convert to Galactic coordinates >>> c.galactic.l <Angle 121.17431 deg> >>> c.galactic.b <Angle -21.57280 deg> Create a separate object in Galactic coordinates >>> from astropy import units as u >>> g = c.transform_to(coords.GalacticCoordinates) >>> g.l.format(u.degree, sep=":", precision=3) '121:10:27.499' Set the distance and view the cartesian coordinates >>> c.distance = coords.Distance(770., u.kpc) >>> c.x 568.7128882165681 >>> c.y 107.30093596881028 >>> c.z 507.8899092486349 Query SIMBAD to get coordinates from object names >>> m = coords.ICRSCoordinates.from_name("M32") >>> m <ICRSCoordinates RA=10.67427 deg, Dec=40.86517 deg> Two coordinates can be used to get distances >>> m.distance = coords.Distance(765., u.kpc) >>> m.separation_3d(c)
def main(): # save the figures figdir = 'Figures' # just listing the wide filters nircam_bandpasses = 'F070W,F090W,F115W,F150W,F200W,F277W,F356W,F444W' miri_bandpasses = 'F560W,F770W,F1000W,F1130W,F1280W,F1500W,F1800W,F2100W,F2550W' nircam_bandpasses = nircam_bandpasses.split(',') miri_bandpasses = miri_bandpasses.split(',') # configure the instruments nircam = W.NIRCam() miri = W.MIRI() # load the bandpasses bandpasses = {} for bp in nircam_bandpasses: nircam.filter = bp bpmodel = nircam._getSynphotBandpass(nircam.filter) bandpasses[bp] = bpmodel for bp in miri_bandpasses: miri.filter = bp bpmodel = miri._getSynphotBandpass(miri.filter) bandpasses[bp] = bpmodel # we just need a couple of bandpasses for testing use_bandpasses = nircam_bandpasses + miri_bandpasses[0:3] # init the kilonova model and create some arrays to store output kn = Kilonova() # do this for a few distances for j, dmpc in enumerate(DISTANCE): time = [] rfphase = [] flux = {} if j == 0: fig = plt.figure(figsize=(8, 15)) ax = fig.add_subplot(1, 1, 1) for i, phase in enumerate(kn._times): # get the kilonova model and spectrum for this phase and distance lam, flam = kn.get_model(phase) lamz, fnorm = kn.get_norm_model(phase, dmpc) name = 'kilonova_{:+.2f}'.format(phase) spec = S.ArraySpectrum(wave=lamz, flux=fnorm, waveunits='angstrom', fluxunits='flam', name=name) # get synthetic mags in each passband for bp in use_bandpasses: passband = bandpasses[bp] obs = S.Observation(spec, passband, force='taper') try: mag = obs.effstim('abmag') except ValueError as e: mag = np.nan thispb = flux.get(bp) if thispb is None: thispb = [ mag, ] else: thispb.append(mag) flux[bp] = thispb # keep a track of rest-frame phase + observer frame days (should make much difference at these distances) dist = c.Distance(dmpc * u.megaparsec) z = dist.z rfphase.append(phase) time.append(phase * (1. + z)) # write output photometry tables if i % 5 == 0: # convert flam -> fnu -> mJy (YUCK) lam_micron = lamz * ANGSTROM_TO_MICRON f_nu = (((lamz * ANGSTROM_TO_CM)**2.) / SPEED_OF_LIGHT) * fnorm / ANGSTROM_TO_MICRON f_mjy = f_nu * FNU_TO_MJY table_name = 'Tables/kilonova_orig_{}Mpc_p{:+.2f}.txt'.format( dmpc, phase) this_spec = at.Table([lam_micron, f_mjy], names=['wave_micron', 'flux_mjy']) this_spec.sort('wave_micron') this_spec.write(table_name, format='ascii.fixed_width', delimiter=' ', overwrite='True') # plot output spectral sequence if j == 0: fplot = flam / flam.mean() ax.plot(lam * ANGSTROM_TO_MICRON, fplot + 180 - i, 'k-') # finalize spectral sequence plot if j == 0: ax.tick_params(axis='both', which='major', labelsize='large') ax.set_xlabel(r'Rest Wavelength ($\mu$m)', fontsize='xx-large') ax.set_ylabel(r'Relative F$_{\lambda}$ + constant', fontsize='xx-large') ax.set_xlim(0.5, 9.5) fig.tight_layout(rect=[0, 0, 1, 0.96]) plt.savefig('{}/kilonova_spec.pdf'.format(figdir)) plt.close(fig) # dump output mag tables arrays = [ rfphase, time, ] + [flux[bp] for bp in use_bandpasses] names = ['rfphase', 'ofphase'] + [bp for bp in use_bandpasses] out = at.Table(arrays, names=names) out.write('Tables/kilonova_phottable_{}Mpc.txt'.format(dmpc), delimiter=' ', format='ascii.fixed_width', overwrite=True) # plot up the lightcurves npbs = len(use_bandpasses) color = iter(plt.cm.tab20(np.linspace(0, 1, npbs))) with PdfPages('{}/kilonova_phot_{}Mpc.pdf'.format(figdir, dmpc)) as pdf: fig = plt.figure(figsize=(10, 10)) for i, bp in enumerate(use_bandpasses): # save four passbands per page if i % 4 == 0 and i > 0: fig.suptitle( 'Kilonova Synthetic Photometry {} Mpc'.format(dmpc), fontsize='xx-large') fig.tight_layout(rect=[0, 0, 1, 0.93]) pdf.savefig(fig) plt.close(fig) fig = plt.figure(figsize=(10, 10)) # plot up a passband ax = fig.add_subplot(2, 2, i % 4 + 1) thiscol = next(color) ax.plot(out['ofphase'], out[bp], marker='o', linestyle='-', lw=0.5, label=bp, color=thiscol) ax.tick_params(axis='both', which='major', labelsize='large') ax.set_ylabel('{} (AB mag)'.format(bp), fontsize='xx-large') ax.set_xlabel('Observer-frame Phase (Days)', fontsize='xx-large') ax.legend(loc='upper right', frameon=False) ymin, ymax = ax.get_ylim() ax.set_ylim((ymax, ymin)) # finalize lightcurve plot if i == npbs - 1: fig.suptitle( 'Kilonova Synthetic Photometry {} Mpc'.format(dmpc), fontsize='xx-large') fig.tight_layout(rect=[0, 0, 1, 0.93]) pdf.savefig(fig) plt.close(fig)
def distance(self): """Assumes 1/parallax. Has shape `(nrows,)`""" return coord.Distance(parallax=self.parallax)