Ejemplo n.º 1
0
 def lightcurve(self, location_a, location_b, range_c=None):
     """Given a pixel index return a lightcurve."""
     return LightCurve(
         DataFrame(
             {
                 "{0},{1}".format(location_a, location_b):
                 self.data[:, location_a, location_b]
             },
             index=self.date))
Ejemplo n.º 2
0
    def slice_to_lightcurve(self, wavelength, y_coord=None, x_coord=None):
        """
        For a time-lambda-y cube, returns a lightcurve with curves at the
        specified wavelength and given y-coordinate. If no y is given, all of
        them will be used (meaning the lightcurve object could contain more
        than one timecurve.)
        Parameters
        ----------
        wavelength: int or astropy quantity
            The wavelength to take the y-coordinates from
        y_coord: int or astropy quantity, optional
            The y-coordinate to take the lightcurve from.
        x_coord: int or astropy quantity, optional
            In the case of hypercubes, specify an extra celestial coordinate.
        """
        if self.axes_wcs.wcs.ctype[0] not in ['TIME', 'UTC']:
            raise cu.CubeError(1,
                               'Cannot create a lightcurve with no time axis')
        if self.axes_wcs.wcs.ctype[1] != 'WAVE':
            raise cu.CubeError(2, 'A spectral axis is needed in a lightcurve')
        if self.data.ndim == 3:
            data = self._choose_wavelength_slice(wavelength)
            if y_coord is not None:
                data = data[:, cu.pixelize(y_coord, self.axes_wcs, 1)]
        else:
            if y_coord is None and x_coord is None:
                raise cu.CubeError(4, "At least one coordinate must be given")
            if y_coord is None:
                y_coord = slice(None, None, None)
            else:
                y_coord = cu.pixelize(y_coord, self.axes_wcs, 2)
            if x_coord is None:
                x_coord = slice(None, None, None)
            else:
                x_coord = cu.pixelize(x_coord, self.axes_wcs, 3)
            item = (slice(None, None, None), wavelength, y_coord, x_coord)
            data = self.data[item]

        return LightCurve(data=data, meta=self.meta)
Ejemplo n.º 3
0
 def _download(uri, kwargs, err='Unable to download data at specified URL',
               filename = None):
     #Create a better filename
     query_str = uri.split('?')[1]
     pars = {}
     for s in query_str.split('&'):
         kv = s.split('=')
         pars.update({kv[0]:kv[1]})
     
     base_url = uri.split('?')[0]
     fname = base_url.split('/')[-1][:-4]
     pars.update({'data_type':fname})
     snumber = base_url.split('/')[-2]
     pars.update({'satellite_number':snumber})
     
     filename = '%s_%s_%s_%s.csv'%(pars['satellite_number'],
                               pars['data_type'],
                               pars['fromDate'],
                               pars['toDate'])
     
     filepath = LightCurve._download(uri,kwargs,filename=filename)
     
     return filepath
Ejemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     LightCurve.__init__(self, *args, **kwargs)
Ejemplo n.º 5
0
# region Description
import sunpy.data.sample
import sunpy.map
aia = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE)
aia.peek()
# endregion

# region Description
import numpy as np
import sunpy.data.sample
from sunpy.lightcurve import LightCurve
times = np.arange(1000) * 2.0
signal = np.sin(np.arange(1000) * 0.02) + np.random.random(1000)
light_curve = LightCurve.create({"signal": signal}, index=times)
light_curve.peek()
# endregion

# region Description
import matplotlib.pyplot as plt
import sunpy.spectra
plt.ion
import sunpy.data.sample
from sunpy.spectra.sources.callisto import CallistoSpectrogram
image = CallistoSpectrogram.read(sunpy.data.sample.CALLISTO_IMAGE)
image.peek()
# endregion

# region Description
import sunpy.map
import matplotlib.pyplot as plt
import sunpy.data.sample
Ejemplo n.º 6
0
Archivo: goes.py Proyecto: jslhs/sunpy
 def __init__(self, *args, **kwargs):
     LightCurve.__init__(self, *args, **kwargs)
Ejemplo n.º 7
0
# sunpy.data.download_sample_data(overwrite=False)
import sunpy.data.sample

aia = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE)
aia.submap([-5, 5] * u.arcsec, [-5, 5] * u.arcsec)


import sunpy.map
import matplotlib.pyplot as plt
import sunpy.data.sample

aia = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE)
fig = plt.figure()
ax = plt.subplot(112)
aia.plot()
aia.draw_limb()
aia.draw_grid()
# plt.colorbar()
aia.draw_limb()
plt.show()


import numpy as np
import sunpy.data.sample
from sunpy.lightcurve import LightCurve

times = np.arange(1000) * 2.0
signal = np.sin(np.arange(1000) * 0.02) + np.random.random(1000)
light_curve = LightCurve.create({"signal": signal}, index=times)
light_curve.peek()