本文整理汇总了Python中pyregion.open函数的典型用法代码示例。如果您正苦于以下问题:Python open函数的具体用法?Python open怎么用?Python open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了open函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_region
def test_region():
ref_region_name = "test01_img.reg"
region_list = ["test01_fk5_sexagecimal.reg",
"test01_gal.reg",
"test01_ds9_physical.reg",
"test01_fk5_degree.reg",
"test01_mixed.reg",
"test01_ciao.reg",
"test01_ciao_physical.reg",
]
header = demo_header()
ref_region = pyregion.open(join(rootdir,ref_region_name)).as_imagecoord(header)
for reg_name in region_list:
r = pyregion.open(join(rootdir,reg_name)).as_imagecoord(header)
for reg0, reg in zip(ref_region, r):
if reg.name == "rotbox":
reg.name = "box"
assert reg0.name == reg.name
if reg0.name in ["ellipse", "box"]:
assert np.allclose(reg0.coord_list[:-1], reg.coord_list[:-1],
atol=0.01)
a0 = reg0.coord_list[-1]
a1 = fix_lon(reg.coord_list[-1], 0)
assert np.allclose([a0], [a1], atol=0.02)
else:
assert np.allclose(reg0.coord_list, reg.coord_list,
atol=0.01)
assert reg0.exclude == reg.exclude
开发者ID:jhunkeler,项目名称:pyregion,代码行数:34,代码来源:test_region.py
示例2: subcubes_from_ds9
def subcubes_from_ds9(cube, region_file='../nro_maps/SouthShells.reg', pad_factor=1., shape='exact'):
"""
Extracts subcubes using the ds9 region file.
Parameters
----------
cube : SpectralCube, str
The cube to be chopped. Must be type spectral_cube.SpectralCube or str filename.
region_file : str
Path to a ds9 region file.
pad_factor : float, optional
Expand the subcube around the region by this factor.
shape : {'square', 'exact'}
The shape of the subcube returned. 'square' returns the
smallest square subcube that contains the region.
'exact' returns only the pixels contained within the region.
Returns
-------
subcubes: list of SpectralCube of SpectralCube
"""
from spectral_cube import SpectralCube
import pyregion
try:
#If cube is a str filename, read a SpectralCube.
cube = SpectralCube.read(cube)
except ValueError:
pass
if shape == 'square':
import astropy.units as u
subcube_list = []
region_list = pyregion.open(region_file)
for region in region_list:
half_width = region.coord_list[2] * pad_factor * u.deg
ra_center = region.coord_list[0] * u.deg
dec_center = region.coord_list[1] * u.deg
ra_range = [ra_center - half_width, ra_center + half_width]
dec_range = [dec_center - half_width, dec_center + half_width]
#print(ra_range, dec_range)
subcube_list.append(cube.subcube(ra_range[1], ra_range[0], dec_range[0], dec_range[1]))
if shape == 'exact':
region_list = pyregion.open(region_file)
subcube_list = []
for region in region_list:
if pad_factor != 1.:
new_string = '{};{}({},{},{}")'.format(region.coord_format, region.name,
region.coord_list[0], region.coord_list[1],
region.coord_list[2]*3600.*pad_factor)
region = pyregion.parse(new_string)[0]
subcube_list.append(cube.subcube_from_ds9region(pyregion.ShapeList([region])))
if len(subcube_list) == 1:
return subcube_list[0]
else:
return subcube_list
开发者ID:jrobbfed,项目名称:carma,代码行数:58,代码来源:shells.py
示例3: __init__
def __init__(self, x, y, regfile, header=None):
""" Parse the ds9 region file here. Also save the number
of regions and the x y dimensions of the data"""
if(header):
self.reg = pyreg.open(regfile).as_imagecoord(header=header)
else:
self.reg = pyreg.open(regfile)
self.filter = self.reg.get_filter()
self.x = x
self.y = y
self.nreg = len(self.reg)
开发者ID:mifumagalli,项目名称:mypython,代码行数:13,代码来源:pyregmask.py
示例4: radioflux
def radioflux(files,fgr,bgr=None,individual=False,action='Flux',fluxerr=0,nsigma=0,verbose=False):
"""Determine the flux in a region file for a set of files. This is the
default action for the code called on the command line, but
may be useful to other code as well.
Keyword arguments:
files -- list of files (mandatory)
fdr -- foreground region name (mandatory)
bgr -- background region name (optional)
individual -- separate region into individual sub-regions
action -- what to do once fluxes are measured: allows a user-defined action
which must be a drop-in replacement for printflux
fluxerr -- flux error in % for spidxmap
nsigma -- keep only pixels above these sigma level in ALL maps (bgr must be specified)
"""
action = {'flux':printflux, 'mean':printmean, 'spidx':printspidx}[action]
rms = [] # radio maps
for filename in files:
rms.append(radiomap(filename,verbose=verbose))
# if using the sigma all the images must have the same size
if nsigma > 0: assert all(rms[i].d[0].size == rms[0].d[0].size for i in range(len(rms)))
# initial mask
mask = (np.zeros_like(rms[0].d) == 0)
bgs = [] #1d list: [ radiomap ]
for rm in rms:
if bgr:
bg_ir=pyregion.open(bgr).as_imagecoord(rm.headers[0])
bg=applyregion(rm,bg_ir)
bgs.append(bg.rms)
# likely brakes with channelled images
if nsigma > 0: mask = np.logical_and(mask, np.array(rm.d) > (np.array(bg.rms)*nsigma) )
else:
bgs.append(None)
fgs = [] # 2d list: [ radiomap x forground_region]
for i, rm in enumerate(rms):
fg_ir=pyregion.open(fgr).as_imagecoord(rm.headers[0])
if individual:
fgs.append([])
for fg_ir_split in fg_ir:
fg=pyregion.ShapeList([fg_ir_split])
fgs[-1].append(applyregion(rm,fg,offsource=bgs[i],mask=mask))
else:
fgs.append([applyregion(rm,fg_ir,offsource=bgs[i],mask=mask)])
# cycle before on regions and than on rm
fgs = np.array(fgs).swapaxes(0,1)
action(fgs, fluxerr)
开发者ID:revoltek,项目名称:scripts,代码行数:51,代码来源:radioflux.py
示例5: photometry
def photometry(dither=1):
# read in region file
if dither == 2:
image,hdr = pyfits.getdata('L1544_J_dither2.fits', header=True)
regpix = pyregion.open('L1544_pix_dither2.reg')
else:
image,hdr = pyfits.getdata('L1544_J_dither1.fits', header=True)
regpix = pyregion.open('L1544_pix_dither1.reg')
nx1 = hdr['NAXIS1']
nx2 = hdr['NAXIS2']
# calc_maglim(image, nx1, nx2)
regsky = pyregion.open('L1544_sky.reg')
names = ('star', 'ra', 'dec', 'xc', 'yc', 'flux', 'eflux',
'mag', 'emag')
dtypes = ('int', 'S11', 'S11', 'float', 'float', 'float', 'float',
'float', 'float')
t = Table(data=None, names=names, dtype=dtypes)
# centroid sources
cenx = np.zeros(len(regpix), dtype=float)
ceny = np.zeros(len(regpix), dtype=float)
for i,star in enumerate(regpix):
id = star.comment
ra = regsky[i].coord_list[0]
dec = regsky[i].coord_list[1]
# x_init = star.coord_list[0]
# y_init = star.coord_list[1]
cenx = star.coord_list[0]
ceny = star.coord_list[1]
# # centroid by fitting a 2D Gaussian
# cenx,ceny = gauss_centroid(image, x_init, y_init)
t.add_row([id, ra, dec, cenx, ceny, 0.0, 0.0, 0.0, 0.0])
# perform aperture photometry
# 30 pixels in radius and sky annuli at 30-50 pixels
table = apphot(image, t, 15, [20,30], return_mag=True)
formats = {'xc':'%8.3f', 'xc':'%8.3f', 'flux':'%7.2f', \
'eflux':'%6.2f', 'mag':'%6.3f', 'emag':'%5.3f'}
if dither == 2:
table.write('flux_dither2.txt', format='ascii.tab', formats=formats)
else:
table.write('flux_dither1.txt', format='ascii.tab', formats=formats)
开发者ID:micaelabagley,项目名称:random-scripts,代码行数:48,代码来源:luciobs.py
示例6: read_mask
def read_mask(maskfile,fitsfile,wolly=False,return_shape=False):
'''Parse mask file and return masked region. If 'wolly' is True, return two masks.'''
import pyregion
if isinstance(fitsfile,str):
hdu = fits.open(fitsfile)
else:
hdu = fitsfile
reg = pyregion.open(maskfile)
# total mask
mask = ~pyregion.get_mask(reg,hdu[0])
if wolly:
# return three masks: (top, bottom, total)
if len(reg) != 2:
raise AttributeError("Wolly masks must have two regions")
# make total mask
reg = [pyregion.ShapeList([r]) for r in reg]
pmask = [~pyregion.get_mask(r,hdu[0]) for r in reg]
pmask.append(mask)
mask = pmask
if return_shape:
shapes = [mask_shape(m) for m in mask]
mask = tuple(pmask + shapes)
#mask is (top,bottom,total,shape_top,shape_bot,shape_total)
else:
if return_shape:
mask = (mask,mask_shape(mask))
return mask
开发者ID:msgordon,项目名称:optipol-reduc,代码行数:31,代码来源:stack.py
示例7: getregionboxcenter
def getregionboxcenter(regionfile):
"""
Extract box center of a DS9 box region.
Input is regionfile Return NDPPP compatible string for phasecenter shifting
"""
r = pyregion.open(regionfile)
if len(r[:]) > 1:
print 'Only one region can be specified, your file contains', len(r[:])
sys.exit()
if r[0].name != 'box':
print 'Only box region supported'
sys.exit()
ra = r[0].coord_list[0]
dec = r[0].coord_list[1]
boxsizex = r[0].coord_list[2]
boxsizey = r[0].coord_list[3]
angle = r[0].coord_list[4]
if boxsizex != boxsizey:
print 'Only a square box region supported, you have these sizes:', boxsizex, boxsizey
sys.exit()
if np.abs(angle) > 1:
print 'Only normally oriented sqaure boxes are supported, your region is oriented under angle:', angle
sys.exit()
regioncenter = ('{:12.8f}'.format(ra) + 'deg,' + '{:12.8f}'.format(dec) + 'deg').replace(' ', '')
return regioncenter
开发者ID:mhardcastle,项目名称:ddf-pipeline,代码行数:29,代码来源:sub-sources-outside-region.py
示例8: ds9
def ds9(regionfile, header, zorder=3, **kwargs):
"""
Wrapper to return a PatchCollection given a ds9 region file
and a fits header.
zorder - defaults to 3 so that regions are on top of contours
"""
# read region file
rr = pyregion.open(regionfile)
# convert coordinates to image coordinates
rrim = rr.as_imagecoord(header)
# pyregion and aplpy both correct for the FITS standard origin=1,1
# need to avoid double-correcting
for r in rrim:
r.coord_list[0] += 1
r.coord_list[1] += 1
if 'text_offset' in kwargs:
text_offset = kwargs['text_offset']
del kwargs['text_offset']
else:
text_offset = 5.0
# grab the shapes to overplot
pp, aa = rrim.get_mpl_patches_texts(text_offset=text_offset)
PC = ArtistCollection(pp, **kwargs) # preserves line style (dashed)
TC = ArtistCollection(aa, **kwargs)
PC.set_zorder(zorder)
TC.set_zorder(zorder)
return PC, TC
开发者ID:hamogu,项目名称:aplpy,代码行数:35,代码来源:regions.py
示例9: _cut_stamps_regions
def _cut_stamps_regions(source_file, region_file, source_ext=0, file_prefix='',
selected_labels=None, **kwargs):
"""
Cuts stamps from a FITS image based on a DS9 region file. See docstring for
cut_stamps for argument explanations
"""
# Open region file first, so parse errors will fail before trying to open
# a potentially large FITS file
regions = pyregion.open(region_file)
# Open cutting image
hdu_list = fits.open(source_file, mode='readonly', ignore_missing_end=True)
# Translate to image coordinates, since we're working in pixel space
regions = regions.as_imagecoord(hdu_list[source_ext].header)
# If a region has a text label, use that as the default file name
# reg.attr[1] is a dictionary of extended region attributes
names = [reg.attr[1].get('text', str(num))
for num, reg in enumerate(regions)]
if selected_labels is None:
selected_labels = set(names)
all_stamp_names = []
for name in set(names) & selected_labels:
regs_for_name = [reg for reg, nm in zip(regions, names) if nm == name]
stamp = _stamp_from_regions(hdu_list, regs_for_name,
extension=source_ext, **kwargs)
filename = file_prefix + name + '.fits'
stamp.writeto(filename, clobber=True)
all_stamp_names += [filename]
hdu_list.close()
return all_stamp_names
开发者ID:mmechtley,项目名称:fitsstamp,代码行数:34,代码来源:fitsstamp.py
示例10: gal2cel
def gal2cel(regfile):
"""
Converts a region file from galactic to celestial coordinates including
position angle reference from the center of the box (right now only works
on box regions)
Requires pyregion with the ShapeList.write() function implemented...
not clear if that exists in 1.0
"""
reg = pyregion.open(regfile)
for R in reg:
if R.name == "box":
x, y, dx, dy, angle = R.coord_list
# posn = coords.Position([x,y],system='galactic')
# ra,dec = posn.j2000()
posn = coordinates.Galactic(x * u.deg, y * u.deg)
ra, dec = posn.fk5.ra.deg, posn.fk5.dec.deg
newang = posang.posang(x - dx, y, x + dx, y, system="galactic")
coord_list = [ra, dec, dx, dy, angle - newang - 90]
R.coord_format = "fk5"
R.coord_list = coord_list
R.params = coord_list
reg.write(regfile[:-4] + "_fk5.reg")
开发者ID:thomaslai78226,项目名称:agpy,代码行数:29,代码来源:reg_gal2cel.py
示例11: make_reg_masks
def make_reg_masks(regfile,shape):
r = pyregion.open(regfile)
if len(r) != 2:
raise Exception('Exactly two box regions required')
paths = []
for reg in r:
paths.append(get_region_box(reg.coord_list))
#Always have A be the top half
if paths[0].get_extents().ymax > paths[1].get_extents().ymax:
pathA = paths[0]
pathB = paths[1]
else:
pathA = paths[1]
pathB = paths[2]
print 'Building skymasks'
maskA = np.array([True if pathA.contains_point([x,y]) else False for x,y in np.ndindex(shape)])
maskA = maskA.reshape(shape).T
maskB = np.array([True if pathB.contains_point([x,y]) else False for x,y in np.ndindex(shape)])
maskB = maskB.reshape(shape).T
return (~maskA, ~maskB)
开发者ID:msgordon,项目名称:optipol-reduc,代码行数:27,代码来源:skysub.py
示例12: show_region
def show_region(fig, region_list):
h = demo_header()
n = len(region_list)
nx = int(math.ceil(n ** .5))
ny = int(math.ceil(1. * n / nx))
nrows_ncols = (ny, nx)
grid = [plt.subplot(ny, nx, i + 1) for i in range(n)]
for ax, reg_name in zip(grid, region_list):
ax.set_aspect(1)
r = pyregion.open(reg_name).as_imagecoord(h)
patch_list, text_list = r.get_mpl_patches_texts()
for p in patch_list:
ax.add_patch(p)
for t in text_list:
ax.add_artist(t)
if plt.rcParams["text.usetex"]:
reg_name = reg_name.replace("_", r"\_")
ax.set_title(reg_name, size=10)
for t in ax.get_xticklabels() + ax.get_yticklabels():
t.set_visible(False)
return grid
开发者ID:astropy,项目名称:pyregion,代码行数:29,代码来源:demo_helper.py
示例13: mask_satellite_trail
def mask_satellite_trail(flc='jcdu36e5q_flc.backup.fits', mask_files=['jcdu36e5q_mask_1.reg', 'jcdu36e5q_mask_2.reg']):
"""
Use Pyregion to mask satellite trails with a region file.
Note: save the region file in "fk5" sky coordinates
"""
import astropy.io.fits as pyfits
import pyregion
### open the FITS image for modifying
im = pyfits.open(flc)
### Make the mask for both "DQ" extensions for both ACS/WFC chips
for extension in [1,2]:
### Get a mask returning 1 *within* the region and 0 elsewhere
im['SCI',extension].header.remove('CPDIS1')
im['SCI',extension].header.remove('CPDIS2')
reg = pyregion.open(mask_files[extension-1]).as_imagecoord(im['SCI', extension].header)
mask = reg.get_mask(im['SCI', extension])
### Apply the mask to the DQ extension
im['DQ', extension].data |= 4096*mask
imf = pyfits.open(flc, mode='update')
for extension in [1,2]:
imf['DQ', extension].data = im['DQ',extension].data
### Write the file
imf.flush()
开发者ID:gbrammer,项目名称:HAWKI-FF,代码行数:28,代码来源:reduce_acs.py
示例14: area_within_reg
def area_within_reg(reg_name,base_fits=m31):
'''
returns deg^s
deg^2 to arcsec^2: areas*3600.*3600.
deg^2 to arcmin^2: areas*3600.
'''
# finds area of concentric reg shapes
# use GenUtils.area for the area of a polygon.
tot_areas,areas = [],[]
proj = wcs.Projection(f_header)
r = pyregion.open(reg_name).as_imagecoord(header=f_header)
patch_list, artist_list = r.get_mpl_patches_texts()
for p in patch_list[::-1]:
verts_xy = p.get_xy()
pixels = (verts_xy[:,0],verts_xy[:,1])
ra_v,dec_v = proj.toworld(pixels)
verts = np.column_stack((ra_v,dec_v))
tot_areas.append(area(verts))
for i in range(len(tot_areas)):
if i == len(tot_areas)-1:
areas.append(tot_areas[i])
else:
areas.append(tot_areas[i]-tot_areas[i+1])
# deg^2 to arcsec^2: areas*3600.*3600.
# deg^2 to arcmin^2: areas*3600.
return np.array(areas)
开发者ID:eduardrusu,项目名称:python,代码行数:28,代码来源:PHATDataUtils.py
示例15: regtoapo
def regtoapo(regfile,outfile,filtercolor=None):
"""
Take an input ds9 .reg file and create an output file
formatted to work with APO's TUI
filtercolor - if specified, will ignore any regions of this color
"""
reg = pyregion.open(regfile)
outf = open(outfile,'w')
for r in reg:
if r.attr[1]['color'] == filtercolor or not r.attr[1].has_key('text'):
continue
if r.name == 'box':
x,y,dx,dy,posang = r.coord_list
radec = position_region(r).hmsdms()
# ds9's position angles are 90 degrees offset from APO's
if posang+90 > 360: posang -= 360
print >>outf,'%32s %26s rotangle=%f' % ( '"%s"' % r.attr[1]['text'],radec,posang+90)
else:
radec = position_region(r).hmsdms()
print >>outf,'%32s %26s' % ('"%s"' % r.attr[1]['text'],radec)
outf.close()
开发者ID:Fade89,项目名称:agpy,代码行数:25,代码来源:regtoapo.py
示例16: do_HIspectra
def do_HIspectra():
hcubes = load_HIcubes()
order = ['HI']
pl.close(1)
fig = pl.figure(1, figsize=(12,8))
colors = ['k','r','g','b','m','#11AAAA']
for regfn in regfiledict:
regions = pyregion.open(regfn)
for r in regions:
spectra = [(c,hcubes[c].get_apspec(r.coord_list,
coordsys=r.coord_format,
wunit='degree'))
for c in order]
fig.clf()
for ii,(hline,sp) in enumerate(spectra):
sp.xarr.convert_to_unit('km/s')
sp.specname = r.attr[1]['text']
sp.unit = 'K'
sp.plotter(figure=fig, xmin=40, xmax=80, color=colors[ii],
clear=False, label=hline)
sp.plotter.axis.set_ylabel("$T_A^*$ (K)")
sp.plotter.savefig(regfiledict[regfn]+"_HI_aperture_%s.pdf" % sp.specname)
sp.write(regfiledict[regfn]+"_HI_aperture_%s.fits" % sp.specname)
开发者ID:keflavich,项目名称:w51_singledish_h2co_maps,代码行数:30,代码来源:pyspeckit_individual_spectra.py
示例17: load_ds9_cloud_region
def load_ds9_cloud_region(props, filename=None, header=None):
import pyregion as pyr
# region[0] in following format:
# [64.26975, 29.342033333333333, 1.6262027777777777, 3.32575, 130.0]
# [ra center, dec center, width, height, rotation angle]
regions = pyr.open(filename)
props['regions'] = {}
for region in regions:
# Cores defined in following format: 'tag={L1495A}'
tag = region.comment
region_name = tag[tag.find('{')+1:tag.find('}')].lower()
# Format vertices to be 2 x N array
poly_verts = []
for i in xrange(0, len(region.coord_list)/2):
poly_verts.append((region.coord_list[2*i],
region.coord_list[2*i+1]))
poly_verts_pix = []
for i in xrange(0, len(poly_verts)):
poly_verts_pix.append(get_pix_coords(ra=poly_verts[i][0],
dec=poly_verts[i][1],
header=header)[:-1][::-1].tolist())
props['regions'][region_name] = {}
props['regions'][region_name]['poly_verts'] = {}
props['regions'][region_name]['poly_verts']['wcs'] = poly_verts
props['regions'][region_name]['poly_verts']['pixel'] = poly_verts_pix
return props
开发者ID:ezbc,项目名称:scripts_and_logs,代码行数:35,代码来源:taurus_analysis_av_load_regions.py
示例18: regtouptime
def regtouptime(regfile,outfile,maxza=15.0):
"""
Converts a region file to a list of target names + how long they are observable @ arecibo
maxza = 15.0 degrees for "broken" Arecibo (2010) or 18-19 for normal Arecibo
"""
# coordinates @ http://www.naic.edu/~astro/guide/node2.html
ra_arecibo = (66+45/60.+11.1/3600.)
dec_arecibo = (18+20/60.+36.6/3600.)
reg = pyregion.open(regfile)
outf = open(outfile,'w')
for r in reg:
#if r.attr[1]['color'] == filtercolor or not r.attr[1].has_key('text'):
# continue
text = pos_to_name(r)
radec = position_region(r).hmsdms()
ra,dec = position_region(r).j2000()
za_min = numpy.abs(dec-dec_arecibo)
# isoscoles triangle with za_min as perpendicular bisector, maxza as long leg lenth
tup = numpy.sqrt(maxza**2-za_min**2)*2.0/15.0 * 60.0 # minutes
print >>outf,'%12s %10.2f %10.1f' % (text,za_min,tup)
outf.close()
开发者ID:Fade89,项目名称:agpy,代码行数:26,代码来源:regtocima.py
示例19: add_cloud_region
def add_cloud_region(core_dict):
import pyregion as pyr
data_dir = '/d/bip3/ezbc/multicloud/data/cold_clumps/'
region_dir = '/d/bip3/ezbc/multicloud/data/python_output/regions/'
#filename = region_dir + 'multicloud_divisions_coldcore_selection.reg'
filename = region_dir + 'multicloud_divisions.reg'
# region[0] in following format:
# [64.26975, 29.342033333333333, 1.6262027777777777, 3.32575, 130.0]
# [ra center, dec center, width, height, rotation angle]
regions = pyr.open(filename)
for region in regions:
# Cores defined in following format: 'tag={L1495A}'
tag = region.comment
region_name = tag[tag.find('{')+1:tag.find('}')].lower()
if region_name in ('taurus', 'california', 'perseus'):
# Format vertices to be 2 x N array
poly_verts = []
for i in xrange(0, len(region.coord_list)/2):
poly_verts.append((region.coord_list[2*i],
region.coord_list[2*i+1]))
for core in core_dict:
if core_dict[core]['cloud'] == region_name:
core_dict[core]['cloud_region_vertices'] = \
np.array(poly_verts)
return core_dict
开发者ID:ezbc,项目名称:scripts_and_logs,代码行数:34,代码来源:cloud_write_parameter_table.py
示例20: set_basic_info
def set_basic_info(self):
"""compile and rename parameters from several catalogs"""
q0 = 0.2
ks = pyfits.open(infodir+'kingfish_sample.fits')[1].data
dk = pyfits.open(infodir+'dalephot_kingfish.fits')[1].data
fkh = pyfits.open(infodir+'fisher_Hband_kingfish.fits')[1].data
sk = pyfits.open(infodir+'skibba_kingfish.fits')[1].data
ak = pyfits.open(infodir+'aniano_kingfish_S250_100_SSS_100_vOct2012.fits')[1].data
reg = pyregion.open(self.kdir+'photometry/dale_region_files'+self.kname+'.deg.reg')
ind = (np.where(ks['NAME'] == self.kname))[0]
self.info['ra'] = ks['RA'][ind]
self.info['dec'] = ks['DEC'][ind]
self.info['dist'] = ak['DIST'][ind]
self.arcsec_to_kpc = self.info['dist']*1e3/206265.0
self.info['a'] = ks['SEMIMAJOR'][ind]
self.info['b'] = ks['SEMIMINOR'][ind]
self.info['pa'] = reg[0].coord_list[2]
q = self.info['b']/self.info['a']
self.info['inclination'] = np.arccos(np.sqrt( (q^2- q0^2)/(1 - q0^2)))*(180./np.pi) + 3.0
self.info['R_e'] = {'obs':fkh['R_EFF_BULGE'][ind]} #half-light radius in arcsec
self.info['mu_e'] = {'obs':fkh['MU_EFF'][ind]} #in AB mag/arcsec**2 at H band
self.info['n_bulge'] = fkh['N_BULGE'][ind] #sersic
self.info['H_disk'] = {'obs':fkh['R_DISK'][ind]} #exponential scale length in arcsec
self.info['mu0'] = {'obs':fkh['MU_0_DISK'][ind]} #in AB mag/arcsec**2 at H band
self.info['R_e']['phys'] = fkh['R_EFF_BULGE'][ind]*self.arcsec_to_kpc #half-light radius in kpc
self.info['H_disk']['phys'] = fkh['R_DISK'][ind]*self.arcsec_to_kpc #exponential scale length in arcsec
#self.info[['mu0']['phys'] =
#self.info[['mu_e']['phys'] =
self.info['morph_band'] = 'twomass_H'
self.info['type'] = sk['MORPH'][ind]
开发者ID:bd-j,项目名称:kingfish,代码行数:33,代码来源:kingfish.py
注:本文中的pyregion.open函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论