From 4fab65b2e2ad7a8559ab912fa99d87886f1e793f Mon Sep 17 00:00:00 2001 From: dead-water Date: Tue, 4 Jun 2024 12:26:18 +0000 Subject: [PATCH] further attempts --- notebooks/synoptic.ipynb | 277 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 277 insertions(+) diff --git a/notebooks/synoptic.ipynb b/notebooks/synoptic.ipynb index 4a07393..5842b6c 100644 --- a/notebooks/synoptic.ipynb +++ b/notebooks/synoptic.ipynb @@ -140,6 +140,283 @@ "# ax.coords.grid(color=\"black\", alpha=0.6, linestyle=\"dotted\", linewidth=0.5)\n", "plt.show()" ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\n", + "\n", + "from astropy.utils.data import download_file\n", + "\n", + "import sunpy.map\n", + "\n", + "filename = download_file(\n", + " 'http://jsoc.stanford.edu/data/hmi/synoptic/hmi.Synoptic_Mr.2191.fits', cache=True)\n", + "syn_map = sunpy.map.Map(filename)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase]\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING: SunpyMetadataWarning: Missing metadata for observer: assuming Earth-based observer.\n", + "For frame 'heliographic_stonyhurst' the following metadata is missing: hglt_obs,dsun_obs,hgln_obs\n", + "For frame 'heliographic_carrington' the following metadata is missing: dsun_obs,crlt_obs,crln_obs\n", + " [sunpy.map.mapbase]\n" + ] + }, + { + "data": { + "text/html": [ + "
<sunpy.map.sources.sdo.HMISynopticMap object at 0x7f519c301540>
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Observatory\t SDO
Instrument\t HMI SIDE1
Detector\t HMI
Measurement\t carrington
Wavelength\t 6173.0 Angstrom
Observation Date 2017-06-09 10:56:34
Exposure Time\t Unknown
Dimension\t [3600. 1440.] pix
Coordinate System heliographic_carrington
Scale\t\t [0.1 0.07957747] deg / pix
Reference Pixel [1799. 719.5] pix
Reference Coord [788580. 0.] deg
\n", + "
\n", + " Image colormap uses histogram equalization
\n", + " Click on the image to toggle between units\n", + "
\n", + " \n", + "
\n", + " Bad pixels are shown in red: 21914 NaN\n", + "
\n", + "
\n", + "
" + ], + "text/plain": [ + "\n", + "SunPy Map\n", + "---------\n", + "Observatory:\t\t SDO\n", + "Instrument:\t\t HMI SIDE1\n", + "Detector:\t\t HMI\n", + "Measurement:\t\t carrington\n", + "Wavelength:\t\t 6173.0 Angstrom\n", + "Observation Date:\t 2017-06-09 10:56:34\n", + "Exposure Time:\t\t Unknown\n", + "Dimension:\t\t [3600. 1440.] pix\n", + "Coordinate System:\t heliographic_carrington\n", + "Scale:\t\t\t [0.1 0.07957747] deg / pix\n", + "Reference Pixel:\t [1799. 719.5] pix\n", + "Reference Coord:\t [788580. 0.] deg \n", + "array([[ nan, nan, nan, ..., nan, nan,\n", + " nan],\n", + " [ nan, nan, nan, ..., nan, nan,\n", + " nan],\n", + " [ nan, nan, nan, ..., 12.601809, 11.882945,\n", + " 8.132867],\n", + " ...,\n", + " [18.471302, 20.34402 , 24.63994 , ..., nan, nan,\n", + " nan],\n", + " [ nan, nan, nan, ..., nan, nan,\n", + " nan],\n", + " [ nan, nan, nan, ..., nan, nan,\n", + " nan]], dtype='>f4')" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "syn_map" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "from sunpy.data.sample import HMI_LOS_IMAGE" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
<sunpy.map.sources.sdo.HMIMap object at 0x7f4fb3b12cb0>
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Observatory\t SDO
Instrument\t HMI FRONT2
Detector\t HMI
Measurement\t magnetogram
Wavelength\t 6173.0
Observation Date 2011-06-07 06:32:11
Exposure Time\t Unknown
Dimension\t [1024. 1024.] pix
Coordinate System helioprojective
Scale\t\t [2.01714 2.01714] arcsec / pix
Reference Pixel [511.5 511.5] pix
Reference Coord [-4.23431983 -0.12852412] arcsec
\n", + "
\n", + " Image colormap uses histogram equalization
\n", + " Click on the image to toggle between units\n", + "
\n", + " \n", + "
\n", + " Bad pixels are shown in red: 321587 NaN\n", + "
\n", + "
\n", + "
" + ], + "text/plain": [ + "\n", + "SunPy Map\n", + "---------\n", + "Observatory:\t\t SDO\n", + "Instrument:\t\t HMI FRONT2\n", + "Detector:\t\t HMI\n", + "Measurement:\t\t magnetogram\n", + "Wavelength:\t\t 6173.0\n", + "Observation Date:\t 2011-06-07 06:32:11\n", + "Exposure Time:\t\t Unknown\n", + "Dimension:\t\t [1024. 1024.] pix\n", + "Coordinate System:\t helioprojective\n", + "Scale:\t\t\t [2.01714 2.01714] arcsec / pix\n", + "Reference Pixel:\t [511.5 511.5] pix\n", + "Reference Coord:\t [-4.23431983 -0.12852412] arcsec \n", + "array([[nan, nan, nan, ..., nan, nan, nan],\n", + " [nan, nan, nan, ..., nan, nan, nan],\n", + " [nan, nan, nan, ..., nan, nan, nan],\n", + " ...,\n", + " [nan, nan, nan, ..., nan, nan, nan],\n", + " [nan, nan, nan, ..., nan, nan, nan],\n", + " [nan, nan, nan, ..., nan, nan, nan]], dtype='>f8')" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "hmimap = sunpy.map.Map(HMI_LOS_IMAGE)\n", + "hmimap" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "from astropy.coordinates import SkyCoord\n", + "\n", + "import sunpy.coordinates\n", + "\n", + "import astropy.units as u\n", + "\n", + "sc = SkyCoord(1*u.deg, 2*u.deg,\n", + " frame=\"heliographic_carrington\",\n", + " observer=\"earth\",\n", + " obstime=\"2010/01/01T00:00:30\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Each 4096*4096 magnetogram is first transformed into a 'radial' field map by dividing by the cosine of the angle from disk center, i.e. we assume that the measured field is the line-of-sight component of a strictly radial field. This is done for high-quality magnetograms, viz. those with the QUALITY keyword tested for bits 0xfffefb00 and keyword TINTNUM>9, see Quality Definitions for more details.)\n", + "\n", + "Next, the radial image is transformed into a high resolution map in heliographic coordinates. We exclude about 12 pixels near the limb (r < 0.994 Rs) to avoid the noisiest observations. To preserve something close to the disc-center resolution, we interpolate onto a 5403 * 4320 grid with columns corresponding to 1/30 of a degree in Carrington Longitude and rows corresponding to equal steps of sine latitude. Then each magnetogram is smoothed using a two-dimensional Gaussian with a full width at half max of 9 pixels that is truncated at a full width of 13 pixels. This results in a 1801 by 1440 heliographic map with the resolution of the final synoptic chart where the columns are aligned to 0.1 degree Carrington longitude centers and rows are equally spaced in sine latitude.\n", + "\n", + "Each point in the final synoptic chart combines data from 20 transformed radial magnetograms. Good data observed nearest central meridian are averaged. Typically this includes magnetogram data collected within 2 hours of central meridian passage. We perform an additional quality test at each point by excluding observations that are more than 3 standard deviations from the mean of the 30 perfect-quality magnetograms observed nearest central meridian. Data values observed farther from central meridian are used to replace bad values. The number of magnetograms contributing to each point is recorded in the epts segment of the data series. Except at high latitude where the poles are not visible, it is rare for there to be other than 20 contributing values. " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "interpol_x = 5403\n", + "interpol_y = 4320\n", + "a_map = np.zeros(5403, 4320)\n", + "for " + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "x, y = hmimap.world_to_pixel(sc)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(, )" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x,y" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {