示例#1
0
def _get_contour(fits_fn, sigma_level):
    with fits.open(fits_fn) as f:
        imgdata = f[0].data
    med = np.nanmedian(imgdata)
    mad = np.nanmedian(np.abs(imgdata - med))
    sigma = mad / mad2sigma
    signal.signal(signal.SIGALRM, _contour_timeout_handler)
    signal.alarm(10)
    try:
        cs = make_contours.contour(fits_fn, sigma * sigma_level, 2.0)
    except TimeoutException as te:
        print("contour timeout on %s" % osp.basename(fits_fn))
        cs = None
    finally:
        signal.alarm(0)
    return cs
示例#2
0
# calculation
mad2sigma = np.sqrt(2) * erfinv(2 * 0.75 - 1)

# the following is needed to derive some statistics when the input radio image is not a SNR image
med = np.median(imgdata)
mad = np.median(np.abs(imgdata - med))
sigma = mad / mad2sigma

import make_contours
from PIL import Image
from matplotlib import pyplot as plt
from matplotlib.pyplot import cm
from matplotlib.path import Path
import matplotlib.patches as patches

cs = make_contours.contour(radio_fits, sigma)
cs['contours'] = map(points_to_dict, cs['contours'])
#print json.dumps(cs)

# Plot the infrared results

fig = plt.figure(1, (12, 4))

# Download contour data

contours = cs

sf_x = 500. / contours['width']
sf_y = 500. / contours['height']

verts_all = []
示例#3
0
# calculation
mad2sigma=np.sqrt(2)*erfinv(2*0.75-1)

# the following is needed to derive some statistics when the input radio image is not a SNR image
med=np.median(imgdata)
mad=np.median(np.abs(imgdata-med))
sigma=mad/mad2sigma

import make_contours
from PIL import Image
from matplotlib import pyplot as plt
from matplotlib.pyplot import cm
from matplotlib.path import Path
import matplotlib.patches as patches

cs = make_contours.contour(radio_fits, sigma)
cs['contours'] = map(points_to_dict, cs['contours'])
#print json.dumps(cs)

# Plot the infrared results

fig = plt.figure(1,(12,4))

# Download contour data

contours = cs

sf_x = 500./contours['width']
sf_y = 500./contours['height']

verts_all = []
    
    # Load the radio data
    radio_fits = '%s/%s_radio.fits' % (imgdir,galname)
    with fits.open(radio_fits) as f:
        imgdata = f[0].data
    
    # convert median absolute difference into sigma in radio image noise calculation
    mad2sigma=np.sqrt(2)*erfinv(2*0.75-1)
    
    # compute sigma for the contour calculation
    med=np.median(imgdata)
    mad=np.median(np.abs(imgdata-med))
    sigma=mad/mad2sigma
    
    # Create contours
    cs = make_contours.contour(radio_fits, sigma * 3, interval)
    cs['contours'] = map(make_contours.points_to_dict, cs['contours'])

    # Write contours to JSON file
    with open('%s/%s_contours.json' % (imgdir,galname),'w') as fobj:
        json.dump(cs,fobj)

    # Load the heatmap data
    
    im_standard = Image.open('%s/%s_heatmap.png' % (imgdir,galname))

    sf_x = float(xsize_pix)/cs['width']
    sf_y = float(ysize_pix)/cs['height']
    
    verts_all = []
    codes_all = []