Skip to content

Commit

Permalink
updates to examples and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tamarervin committed Nov 15, 2021
1 parent 3f1aa2e commit d16fcb7
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 216 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ outlines the corrections and component calculation pipeline

3. [RV Calculations](https://github.com/tamarervin/sdo_hmi_rvs/blob/main/sdo_hmi_rvs/examples/rv_calculation.ipynb):
outlines calculation of full model RV from velocity components
* requires input CSV with velocity components from [example 2](https://github.com/tamarervin/sdo_hmi_rvs/blob/main/sdo_hmi_rvs/examples/component_calculations.ipynb)

* requires input CSV with velocity components from [example 2](https://github.com/tamarervin/sdo_hmi_rvs/blob/main/sdo_hmi_rvs/examples/component_calculations.ipynb)
* an example CSV file with calculations is stored [here](https://github.com/tamarervin/sdo_hmi_rvs/blob/main/sdo_hmi_rvs/products/csv_files/calcs/example_calcs.csv)

4. [Full Pipeline](https://github.com/tamarervin/sdo_hmi_rvs/blob/main/sdo_hmi_rvs/examples/full_pipeline.ipynb):
full end-to-end pipeline to calculate 'sun-as-a-star' RVs and magnetic observables

6 changes: 5 additions & 1 deletion mkdocs/docs/examples/docs_rv_calcs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"\n",
"1. **calculate solar velocities:** calculate solar velocities and save to csv\n",
"2. **get component lists:** using pandas to get the lists of each relevant component\n",
"3. **calculate RVs and save to csv:** calculate RVs using optimized parameters"
"3. **calculate RVs and save to csv:** calculate RVs using optimized parameters\n",
"\n",
"\n",
"**NOTE:** this is purely an example but requires ground-based Solar RV\n",
"measurements for fitting"
],
"metadata": {
"collapsed": false
Expand Down
3 changes: 2 additions & 1 deletion mkdocs/docs/examples/docs_solar_corrections.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@
"execution_count": null,
"outputs": [],
"source": [
"map_int_cor = [sfuncs.corrected_map(Iflat[i], hmi_int[i], map_type='Corrected-Intensitygram', frame=frames.HeliographicCarrington) for i in range(0, len(hmi_int))]"
"map_int_cor = [sfuncs.corrected_map(Iflat[i], hmi_int[i], map_type='Corrected-Intensitygram',\n",
" frame=frames.HeliographicCarrington) for i in range(0, len(hmi_int))]"
],
"metadata": {
"collapsed": false,
Expand Down
24 changes: 12 additions & 12 deletions mkdocs/site/examples/docs_solar_corrections/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1692,8 +1692,8 @@ <h2 id="step-one-coordinate-transformation">Step One: Coordinate Transformation<
<div class="jp-Cell-inputWrapper"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
<p>Apply coordinate transformations for HMI data products where:</p>
<p><code>x, y, pd, r, d, mu = coord[i][0], coord[i][1], coord[i][2], coord[i][3], coord[i][4], coord[i][5]<code></p>
<p><code>wij, nij, rij = vel_coords[i][0], vel_coords[i][1], vel_coords[i][2]<code></p>
<p><code>x, y, pd, r, d, mu = coord[i][0], coord[i][1], coord[i][2], coord[i][3], coord[i][4], coord[i][5]</code></p>
<p><code>wij, nij, rij = vel_coords[i][0], vel_coords[i][1], vel_coords[i][2]</code></p>

</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs ">
Expand Down Expand Up @@ -1737,7 +1737,7 @@ <h2 id="step-one-coordinate-transformation">Step One: Coordinate Transformation<
<div class="jp-Cell-inputWrapper"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
<p>Remove bad mu values from each map.</p>
<p><code>hmi_vel, hmi_mag, imap = maps[i][0], maps[i][1], maps[i][2]<code></p>
<p><code>hmi_vel, hmi_mag, imap = maps[i][0], maps[i][1], maps[i][2]</code></p>

</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs ">
Expand Down Expand Up @@ -1790,7 +1790,7 @@ <h2 id="step-two-calculate-spacecraft-velocity">Step Two: Calculate Spacecraft V
<div class="jp-Cell-inputWrapper"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
<p>Calculate relative positions.</p>
<p><code>deltaw, deltan, deltar, dij = delta[i][0], delta[i][1], delta[i][2], delta[i][3]<code></p>
<p><code>deltaw, deltan, deltar, dij = delta[i][0], delta[i][1], delta[i][2], delta[i][3]</code></p>

</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs ">
Expand Down Expand Up @@ -2279,7 +2279,7 @@ <h2 id="step-five-unsigned-magnetic-field-strength">Step Five: Unsigned Magnetic
<p>We calculate radial unsigned magnetic field strength and set pixels with an
observed magnetic field below the noise value equal to zero.</p>
<p>The noise level used is from Yeo et al. 2013, and is 8 Gauss.</p>
<p><code>Bobs, Br = corrected_mag[0], corrected_mag[1]<code></p>
<p><code>Bobs, Br = corrected_mag[0], corrected_mag[1]</code></p>

</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs ">
Expand Down Expand Up @@ -2524,7 +2524,7 @@ <h3 id="part-one-magnetic-thresholding">Part One: Magnetic Thresholding<a class=
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
<p>For weighting, we return an active weights array (active = 1) and quiet weights array (active = 0).</p>
<p>Get threshold maps where:</p>
<p><code>active, quiet = mag_thresh[i][0], mag_thresh[i][1]<code></p>
<p><code>active, quiet = mag_thresh[i][0], mag_thresh[i][1]</code></p>

</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs ">
Expand Down Expand Up @@ -2648,7 +2648,7 @@ <h3 id="part-two-intensity-thresholding">Part Two: Intensity Thresholding<a clas
<div class="jp-Cell-inputWrapper"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
<p>Calculate intensity threshold value and differentiate between sunspots and faculae where:</p>
<p><code>fac_inds, spot_inds = int_thresh[0], int_thresh[1]<code></p>
<p><code>fac_inds, spot_inds = int_thresh[0], int_thresh[1]</code></p>

</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs ">
Expand Down Expand Up @@ -3047,7 +3047,7 @@ <h2 id="step-two-photometric-velocity-due-to-rotational-doppler-imbalance">Step
<div class="jp-Cell-inputWrapper"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
<p>Calculate photometric velocity.</p>
<p><code>v_phot, vphot_bright, vphot_spot = vphot[0], vphot[1], vphot[2]<code></p>
<p><code>v_phot, vphot_bright, vphot_spot = vphot[0], vphot[1], vphot[2]</code></p>

</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs ">
Expand Down Expand Up @@ -3183,7 +3183,7 @@ <h1 id="magnetic-observables">Magnetic Observables<a class="anchor-link" href="#
<h2 id="filling-factor">Filling Factor<a class="anchor-link" href="#Filling-Factor">&#182;</a></h2><p>Estimate the disc-averaged filling factors of sunspots and plage:
$ f_{spot, plage} = \frac{1}{N_{pix}} \sum_{ij} W_{ij} $</p>
<p>In this case, a weight of 1 is an active pixel (active_weights).</p>
<p><code>f_bright, f_spot, f = filling[0], filling[1], filling[2]<code></p>
<p><code>f_bright, f_spot, f = filling[0], filling[1], filling[2]</code></p>

</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs ">
Expand Down Expand Up @@ -3306,7 +3306,7 @@ <h2 id="area-based-observable-calculations">Area Based Observable Calculations<a
<div class="jp-Cell-inputWrapper"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
<p>Calculate the area filling factor.</p>
<p><code>f_small, f_large, f_network, f_plage, f_nonconv = f_area[0], f_area[1], f_area[2], f_area[3], f_area[4]<code></p>
<p><code>f_small, f_large, f_network, f_plage, f_nonconv = f_area[0], f_area[1], f_area[2], f_area[3], f_area[4]</code></p>

</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs ">
Expand Down Expand Up @@ -3342,7 +3342,7 @@ <h2 id="area-based-observable-calculations">Area Based Observable Calculations<a
<div class="jp-Cell-inputWrapper"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
<p>Calculate unsigned flux of various polarized and active regions.</p>
<p><code>quiet_flux, ar_flux, conv_flux, pol_flux, pol_conv_flux = flux[0], flux[1], flux[2], flux[3], flux[4], flux[5]<code></p>
<p><code>quiet_flux, ar_flux, conv_flux, pol_flux, pol_conv_flux = flux[0], flux[1], flux[2], flux[3], flux[4], flux[5]</code></p>

</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs ">
Expand Down Expand Up @@ -3380,7 +3380,7 @@ <h2 id="area-based-observable-calculations">Area Based Observable Calculations<a
<div class="jp-Cell-inputWrapper"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
<p>Get area weighted convective velocities.</p>
<p><code>vconv_quiet, vconv_large, vconv_small = vconv_area[0], vconv_area[1], vconv_area[2]<code></p>
<p><code>vconv_quiet, vconv_large, vconv_small = vconv_area[0], vconv_area[1], vconv_area[2]</code></p>

</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs ">
Expand Down
4 changes: 2 additions & 2 deletions mkdocs/site/examples/docs_sunpy_example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1698,9 +1698,9 @@ <h2 id="querying-data">Querying data<a class="anchor-link" href="#Querying-data"



<div id="4132b656-924c-40ab-859e-79e8cac1261a" class="jupyter-widgets jp-OutputArea-output ">
<div id="5855610c-7341-4652-aba4-92757f219a37" class="jupyter-widgets jp-OutputArea-output ">
<script type="text/javascript">
var element = document.getElementById('4132b656-924c-40ab-859e-79e8cac1261a');
var element = document.getElementById('5855610c-7341-4652-aba4-92757f219a37');
</script>
<script type="application/vnd.jupyter.widget-view+json">
{"model_id": "562e80d0aa5b4548a33015eae2ee8169", "version_major": 2, "version_minor": 0}
Expand Down
2 changes: 1 addition & 1 deletion mkdocs/site/package/calculation_funcs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2383,7 +2383,7 @@ <h4 id="sdo_hmi_rvs.tools.calculation_funcs.mag_thresh--returns">Returns</h4>


<h2 id="sdo_hmi_rvs.tools.calculation_funcs.map_sequence" class="doc doc-heading">
<code class="highlight language-python"><span class="n">map_sequence</span><span class="p">(</span><span class="n">dates_list</span><span class="p">,</span> <span class="n">time_range</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">timedelta</span><span class="p">(</span><span class="n">seconds</span><span class="o">=</span><span class="mi">6</span><span class="p">),</span> <span class="n">instrument</span><span class="o">=&lt;</span><span class="n">sunpy</span><span class="o">.</span><span class="n">net</span><span class="o">.</span><span class="n">attrs</span><span class="o">.</span><span class="n">Instrument</span><span class="p">(</span><span class="n">AIA</span><span class="p">:</span> <span class="n">Atmospheric</span> <span class="n">Imaging</span> <span class="n">Assembly</span><span class="p">)</span> <span class="nb">object</span> <span class="n">at</span> <span class="mh">0x7fcbd5a482b0</span><span class="o">&gt;</span><span class="p">,</span> <span class="n">wavelength</span><span class="o">=&lt;</span><span class="n">sunpy</span><span class="o">.</span><span class="n">net</span><span class="o">.</span><span class="n">attrs</span><span class="o">.</span><span class="n">Wavelength</span><span class="p">(</span><span class="mf">171.0</span><span class="p">,</span> <span class="mf">171.0</span><span class="p">,</span> <span class="s1">&#39;Angstrom&#39;</span><span class="p">)</span><span class="o">&gt;</span><span class="p">)</span></code>
<code class="highlight language-python"><span class="n">map_sequence</span><span class="p">(</span><span class="n">dates_list</span><span class="p">,</span> <span class="n">time_range</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">timedelta</span><span class="p">(</span><span class="n">seconds</span><span class="o">=</span><span class="mi">6</span><span class="p">),</span> <span class="n">instrument</span><span class="o">=&lt;</span><span class="n">sunpy</span><span class="o">.</span><span class="n">net</span><span class="o">.</span><span class="n">attrs</span><span class="o">.</span><span class="n">Instrument</span><span class="p">(</span><span class="n">AIA</span><span class="p">:</span> <span class="n">Atmospheric</span> <span class="n">Imaging</span> <span class="n">Assembly</span><span class="p">)</span> <span class="nb">object</span> <span class="n">at</span> <span class="mh">0x7f8677384f70</span><span class="o">&gt;</span><span class="p">,</span> <span class="n">wavelength</span><span class="o">=&lt;</span><span class="n">sunpy</span><span class="o">.</span><span class="n">net</span><span class="o">.</span><span class="n">attrs</span><span class="o">.</span><span class="n">Wavelength</span><span class="p">(</span><span class="mf">171.0</span><span class="p">,</span> <span class="mf">171.0</span><span class="p">,</span> <span class="s1">&#39;Angstrom&#39;</span><span class="p">)</span><span class="o">&gt;</span><span class="p">)</span></code>


</h2>
Expand Down
2 changes: 1 addition & 1 deletion mkdocs/site/search/search_index.json

Large diffs are not rendered by default.

Binary file modified mkdocs/site/sitemap.xml.gz
Binary file not shown.
29 changes: 17 additions & 12 deletions sdo_hmi_rvs/examples/full_pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 24,
"outputs": [
{
"data": {
Expand All @@ -710,24 +710,26 @@
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"# set up plotting style\n",
"plot_style = os.path.join(PlotDir.MPL, 'figure_series.mplstyle')\n",
"plt.rcParams['mathtext.fontset'] = 'custom'\n",
"plt.rcParams['mathtext.cal'] = 'Helvetica Neue LT Pro'\n",
"plt.style.use(plot_style)\n",
"\n",
"# date to plot\n",
"date_jd = component_df.date_jd.values\n",
"x = date_jd - date_jd[0]\n",
"\n",
"y_list = [component_df.f.values, component_df.Bobs.values, component_df.v_conv.values, component_df.v_phot.values,\n",
" component_df.rv_model.values - np.median(component_df.rv_model.values)]\n",
"\n",
"# plot labels\n",
"xlabel = 'Days since ' + str(int(date_jd[0])) + ' JD'\n",
"ylabel_list = [r'$\\rm f$' '\\n' r'$\\rm$[%]',\n",
" r'$\\rm B_{\\rm obs}$' '\\n' r'$\\rm [G]$',\n",
" r'$\\rm v_{\\rm conv}$' '\\n' r'$\\rm[m s^{-1}]$',\n",
" r'$\\rm v_{\\rm phot}$' '\\n' r'$\\rm[m s^{-1}]$',\n",
" r'$\\rm RV_{\\rm model}$' '\\n' r'$\\rm[m s^{-1}]$']\n",
"\n",
"\n",
"plot_style = os.path.join(PlotDir.MPL, 'figure_series.mplstyle')\n",
"plt.rcParams['mathtext.fontset'] = 'custom'\n",
"plt.rcParams['mathtext.cal'] = 'Helvetica Neue LT Pro'\n",
"plt.style.use(plot_style)\n",
"\n",
"# set up figure\n",
"fig, axs = plt.subplots(len(y_list), 1, sharex='all', figsize=[6, 1.5 * len(y_list)], gridspec_kw={'hspace': 0})\n",
"\n",
Expand All @@ -740,6 +742,7 @@
" yticks = np.arange(y_list[i].min(), y_list[i].max()+0.0002, step=step*2)\n",
" axs[i].set(ylim=ylim, yticks=yticks)\n",
"\n",
"# create x-axis ticks and labels\n",
"axs[i].set(xlabel=xlabel)\n",
"rng = (x.max() - x.min())\n",
"step = int(rng/6)\n",
Expand All @@ -758,7 +761,11 @@
"\n",
"\n",
"# align y axis labels\n",
"fig.align_ylabels(axs)"
"fig.align_ylabels(axs)\n",
"\n",
"# save figure\n",
"fig_path = os.path.join(ImgDir.IMG_DIR, 'example_rv_comp.png')\n",
"fig.savefig(fig_path)\n"
],
"metadata": {
"collapsed": false,
Expand All @@ -771,9 +778,7 @@
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"\n"
],
"source": [],
"metadata": {
"collapsed": false,
"pycharm": {
Expand Down
2 changes: 1 addition & 1 deletion sdo_hmi_rvs/examples/rv_calculation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"outputs": [],
"source": [
"# csv file with rv components\n",
"csv_file = os.path.join(CsvDir.CALC, 'csv_name.csv')"
"csv_file = os.path.join(CsvDir.CALC, 'example_calcs.csv')"
],
"metadata": {
"collapsed": false,
Expand Down
Binary file added sdo_hmi_rvs/products/images/example_rv_comp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions sdo_hmi_rvs/tools/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ class ImgDir:
IMG_DIR = os.path.join(BaseDir.BASE_DIR, 'images')


class PlotDir:
"""
Directories that hold plotting style files
"""
MPL = os.path.join(BaseDir.BASE_DIR, 'mplstyle')


class Scaling:
"""
Class that holds scaling coefficients for RV calculations.
Expand Down Expand Up @@ -60,9 +67,3 @@ class NEID(Scaling):
B = 1.423
RV0 = -646.076


class PlotDir:
"""
Directories that hold plotting style files
"""
MPL = os.path.join(BaseDir.BASE_DIR, 'mplstyle')
119 changes: 0 additions & 119 deletions sdo_hmi_rvs/tools/settings_tamar.py

This file was deleted.

Loading

0 comments on commit d16fcb7

Please sign in to comment.