def joinFileSRS(fileName):
    try:
        print(fileName)
        srs_table = srs.read_srs(fileName)
        # print(srs_table)
        # print(srs_table.colnames)
        print(srs_table.meta['issued'].date())
        outF = open("Data set\\01-ALL_SRS.csv", "a")
        for x in srs_table:

            LatitudeNumber = re.search("\d+", str(x['Latitude']))
            LongitudeNumber = re.search("\d+", str(x['Longitude']))

            stringX = "{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10}\n".format(
                x['ID'], x['Number'], x['Carrington Longitude'], x['Area'],
                x['Z'], x['Longitudinal Extent'], x['Number of Sunspots'],
                x['Mag Type'],
                LatitudeNumber.group(0) if LatitudeNumber else 0,
                LongitudeNumber.group(0) if LongitudeNumber else 0,
                srs_table.meta['issued'].date())
            # print(stringX)
            outF.write(stringX)

        outF.close()

    except KeyError as err:
        print("KeyError: {0}".format(err))
# filename.

file_name = Fido.fetch(result)

##############################################################################
# Download the SRS file.

srs_results = Fido.search(a.Time(start_time, end_time),
                          a.Instrument('SRS_TABLE'))
srs_downloaded_files = Fido.fetch(srs_results)

##############################################################################
# We get one SRS file per day. To read this file, we pass the filename into
# the SRS reader. So now `srs_table` contains an astropy table.

srs_table = srs.read_srs(srs_downloaded_files[0])
print(srs_table)

##############################################################################
# We only need the rows which have 'ID' = 'I' or 'IA'.

if 'I' in srs_table['ID'] or 'IA' in srs_table['ID']:
    srs_table = srs_table[np.logical_or(srs_table['ID'] == 'I',
                                        srs_table['ID'] == 'IA')]
else:
    print("Warning : No I or IA entries for this date.")
    srs_table = None

##############################################################################
# Now we extract the latitudes, longitudes and the region numbers. We make an
# empty list if there are no ARs.
Beispiel #3
0
def test_number_of_rows(path, number_of_rows):
    table = srs.read_srs(path)
    assert len(table) == number_of_rows
# used indexing to get the first file of the day, the list contains one
# filename.

file_name = Fido.fetch(result)

##############################################################################
# Download the SRS file.

srs_results = Fido.search(a.Time(start_time, end_time), a.Instrument('SRS_TABLE'))
srs_downloaded_files = Fido.fetch(srs_results)

##############################################################################
# We get one SRS file per day. To read this file, we pass the filename into
# the SRS reader. So now `srs_table` contains an astropy table.

srs_table = srs.read_srs(srs_downloaded_files[0])
print(srs_table)

##############################################################################
# We only need the rows which have 'ID' = 'I' or 'IA'.

if 'I' in srs_table['ID'] or 'IA' in srs_table['ID']:
    srs_table = srs_table[np.logical_or(srs_table['ID'] == 'I',
                                        srs_table['ID'] == 'IA')]
else:
    print("Warning : No I or IA entries for this date.")
    srs_table = None

##############################################################################
# Now we extract the latitudes, longitudes and the region numbers. We make an
# empty list if there are no ARs.
Beispiel #5
0
import numpy as np

from astropy.coordinates import SkyCoord

import sunpy.coordinates
import sunpy.data.sample
import sunpy.map
from sunpy.io.special import srs

##############################################################################
# For this example, we will start with the sample data. We need an HMI file and
# use it to create a map, and the SRS table which contains a list of active
# regions. Both of these data can be downloaded with ``Fido``.

smap = sunpy.map.Map(sunpy.data.sample.HMI_LOS_IMAGE)
srs_table = srs.read_srs(sunpy.data.sample.SRS_TABLE)

##############################################################################
# We only need the rows which have 'ID' = 'I' or 'IA'.

srs_table = srs_table[np.logical_or(srs_table['ID'] == 'I',
                                    srs_table['ID'] == 'IA')]

##############################################################################
# Now we extract the latitudes, longitudes and the region numbers.
# :meth:`~astropy.visualization.wcsaxes.WCSAxes.plot_coord` will error on some
# versions of Astropy if a coordinate component contains a mask, but since
# none of the masks in these arrays here actually mask any elements, we simply
# remove the masks.

lats = srs_table['Latitude']
Beispiel #6
0
def test_number_of_rows(path, number_of_rows):
    table = srs.read_srs(path)
    assert len(table) == number_of_rows
plt.figure()
rhessi_map.plot()
plt.show()

##############################################################################
# NORH

norh = sunpy.timeseries.TimeSeries(sample_data.NORH_TIMESERIES)
fig = plt.figure()
norh.plot()
plt.show()

####################################################################################
# NOAA overlaid with HMI

noaa = srs.read_srs(sample_data.SRS_TABLE)
smap = sunpy.map.Map(sample_data.HMI_LOS_IMAGE)

noaa = noaa[np.logical_or(noaa['ID'] == 'I', noaa['ID'] == 'IA')]

lats = noaa['Latitude']
lngs = noaa['Longitude']
numbers = noaa['Number']

fig = plt.figure()
ax = fig.add_subplot(projection=smap)

smap.plot_settings["norm"].vmin = -200
smap.plot_settings["norm"].vmax = 200
smap.plot(axes=ax)
smap.draw_limb(axes=ax)