Beispiel #1
0
def backprojection(calibrated_event_list, pixel_size=(1.0, 1.0), image_dim=(64, 64)):
    """Given a stacked calibrated event list fits file create a back projection image."""
    import sunpy.sun.constants as sun
    from sunpy.sun.sun import angular_size
    from sunpy.sun.sun import sunearth_distance
    from sunpy.time.util import TimeRange

    calibrated_event_list = sunpy.RHESSI_EVENT_LIST
    fits = pyfits.open(calibrated_event_list)
    info_parameters = fits[2]
    xyoffset = info_parameters.data.field("USED_XYOFFSET")[0]
    time_range = TimeRange(info_parameters.data.field("ABSOLUTE_TIME_RANGE")[0])

    image = np.zeros(image_dim)

    # find out what detectors were used
    det_index_mask = fits[1].data.field("det_index_mask")[0]
    detector_list = (np.arange(9) + 1) * np.array(det_index_mask)
    for detector in detector_list:
        if detector > 0:
            image = image + _backproject(
                calibrated_event_list, detector=detector, pixel_size=pixel_size, image_dim=image_dim
            )

    dict_header = {
        "DATE-OBS": time_range.center().strftime("%Y-%m-%d %H:%M:%S"),
        "CDELT1": pixel_size[0],
        "NAXIS1": image_dim[0],
        "CRVAL1": xyoffset[0],
        "CRPIX1": image_dim[0] / 2 + 0.5,
        "CUNIT1": "arcsec",
        "CTYPE1": "HPLN-TAN",
        "CDELT2": pixel_size[1],
        "NAXIS2": image_dim[1],
        "CRVAL2": xyoffset[1],
        "CRPIX2": image_dim[0] / 2 + 0.5,
        "CUNIT2": "arcsec",
        "CTYPE2": "HPLT-TAN",
        "HGLT_OBS": 0,
        "HGLN_OBS": 0,
        "RSUN_OBS": angular_size(time_range.center()),
        "RSUN_REF": sun.radius,
        "DSUN_OBS": sunearth_distance(time_range.center()) * sunpy.sun.constants.au,
    }

    header = sunpy.map.MapHeader(dict_header)
    result_map = sunpy.map.BaseMap(image, header)

    return result_map
Beispiel #2
0
 def get_properties(cls, header):
     """Parses EIT image header"""
     properties = Map.get_properties(header)
     
     # Solar radius in arc-seconds at 1 au
     radius_1au = sun.angular_size(header.get('date_obs'))
     
     scale = header.get("cdelt1")
     # EIT solar radius is expressed in number of EIT pixels
     solar_r = header.get("solar_r")
     
     properties.update({
         "date": parse_time(header.get('date_obs')),
         "detector": "EIT",
         "rsun_arcseconds": solar_r * scale,
         "dsun": ((radius_1au / 
                   (solar_r * scale)) * constants.au),
         "name": "EIT %s" % header.get('wavelnth'),
         "nickname": "EIT",
         "cmap": cm.get_cmap('sohoeit%d' % header.get('wavelnth'))
     })
     return properties
Beispiel #3
0
def backprojection(calibrated_event_list, pixel_size=(1.,1.), image_dim=(64,64)):
    """Given a stacked calibrated event list fits file create a back 
    projection image.
    
    .. warning:: The image is not in the right orientation!

    Parameters
    ----------
    calibrated_event_list : string
        filename of a RHESSI calibrated event list
    detector : int
        the detector number
    pixel_size : 2-tuple
        the size of the pixels in arcseconds. Default is (1,1).
    image_dim : 2-tuple
        the size of the output image in number of pixels

    Returns
    -------
    out : RHESSImap
        Return a backprojection map.

    Examples
    --------
    >>> import sunpy.instr.rhessi as rhessi
    >>> map = rhessi.backprojection(sunpy.RHESSI_EVENT_LIST)
    >>> map.show()

    """
    
    calibrated_event_list = sunpy.RHESSI_EVENT_LIST
    fits = pyfits.open(calibrated_event_list)
    info_parameters = fits[2]
    xyoffset = info_parameters.data.field('USED_XYOFFSET')[0]
    time_range = TimeRange(info_parameters.data.field('ABSOLUTE_TIME_RANGE')[0])
    
    image = np.zeros(image_dim)
    
    #find out what detectors were used
    det_index_mask = fits[1].data.field('det_index_mask')[0]    
    detector_list = (np.arange(9)+1) * np.array(det_index_mask)
    for detector in detector_list:
        if detector > 0:
            image = image + _backproject(calibrated_event_list, detector=detector, pixel_size=pixel_size, image_dim=image_dim)
    
    dict_header = {
        "DATE-OBS": time_range.center().strftime("%Y-%m-%d %H:%M:%S"), 
        "CDELT1": pixel_size[0],
        "NAXIS1": image_dim[0],
        "CRVAL1": xyoffset[0],
        "CRPIX1": image_dim[0]/2 + 0.5, 
        "CUNIT1": "arcsec",
        "CTYPE1": "HPLN-TAN",
        "CDELT2": pixel_size[1],
        "NAXIS2": image_dim[1],
        "CRVAL2": xyoffset[1],
        "CRPIX2": image_dim[0]/2 + 0.5,
        "CUNIT2": "arcsec",
        "CTYPE2": "HPLT-TAN",
        "HGLT_OBS": 0,
        "HGLN_OBS": 0,
        "RSUN_OBS": angular_size(time_range.center()),
        "RSUN_REF": sun.radius,
        "DSUN_OBS": sunearth_distance(time_range.center()) * sunpy.sun.constants.au
    }
    
    header = sunpy.map.MapHeader(dict_header)
    result_map = sunpy.map.Map(image, header)
            
    return result_map
Beispiel #4
0
def backprojection(calibrated_event_list,
                   pixel_size=(1., 1.),
                   image_dim=(64, 64)):
    """Given a stacked calibrated event list fits file create a back 
    projection image.
    
    .. warning:: The image is not in the right orientation!

    Parameters
    ----------
    calibrated_event_list : string
        filename of a RHESSI calibrated event list
    detector : int
        the detector number
    pixel_size : 2-tuple
        the size of the pixels in arcseconds. Default is (1,1).
    image_dim : 2-tuple
        the size of the output image in number of pixels

    Returns
    -------
    out : RHESSImap
        Return a backprojection map.

    Examples
    --------
    >>> import sunpy.instr.rhessi as rhessi
    >>> map = rhessi.backprojection(sunpy.RHESSI_EVENT_LIST)
    >>> map.show()

    """

    calibrated_event_list = sunpy.RHESSI_EVENT_LIST
    fits = pyfits.open(calibrated_event_list)
    info_parameters = fits[2]
    xyoffset = info_parameters.data.field('USED_XYOFFSET')[0]
    time_range = TimeRange(
        info_parameters.data.field('ABSOLUTE_TIME_RANGE')[0])

    image = np.zeros(image_dim)

    #find out what detectors were used
    det_index_mask = fits[1].data.field('det_index_mask')[0]
    detector_list = (np.arange(9) + 1) * np.array(det_index_mask)
    for detector in detector_list:
        if detector > 0:
            image = image + _backproject(calibrated_event_list,
                                         detector=detector,
                                         pixel_size=pixel_size,
                                         image_dim=image_dim)

    dict_header = {
        "DATE-OBS": time_range.center().strftime("%Y-%m-%d %H:%M:%S"),
        "CDELT1": pixel_size[0],
        "NAXIS1": image_dim[0],
        "CRVAL1": xyoffset[0],
        "CRPIX1": image_dim[0] / 2 + 0.5,
        "CUNIT1": "arcsec",
        "CTYPE1": "HPLN-TAN",
        "CDELT2": pixel_size[1],
        "NAXIS2": image_dim[1],
        "CRVAL2": xyoffset[1],
        "CRPIX2": image_dim[0] / 2 + 0.5,
        "CUNIT2": "arcsec",
        "CTYPE2": "HPLT-TAN",
        "HGLT_OBS": 0,
        "HGLN_OBS": 0,
        "RSUN_OBS": angular_size(time_range.center()),
        "RSUN_REF": sun.radius,
        "DSUN_OBS":
        sunearth_distance(time_range.center()) * sunpy.sun.constants.au
    }

    header = sunpy.map.MapHeader(dict_header)
    result_map = sunpy.map.Map(image, header)

    return result_map