Skip to content

Commit

Permalink
Merge pull request #94 from spacetelescope/ci-fix
Browse files Browse the repository at this point in the history
Fixing errors in CI
  • Loading branch information
snbianco authored Feb 9, 2025
2 parents ca6f989 + 0464d36 commit 7e51c5c
Show file tree
Hide file tree
Showing 12 changed files with 246 additions and 257 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,13 @@
"cell_type": "code",
"execution_count": null,
"id": "fc1e4e13",
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"# We use a radius of zero to find exact matches\n",
"obs_table_nodust = Observations.query_criteria(obs_collection=\"IUE\",\n",
" objectname=target_nodust,\n",
" radius = \"0m\")\n",
" objectname=target_nodust,\n",
" radius=\"0m\")\n",
"len(obs_table_nodust)"
]
},
Expand All @@ -185,7 +183,7 @@
"outputs": [],
"source": [
"# Display the matching observations, if you want\n",
"obs_table_nodust.show_in_notebook()"
"obs_table_nodust"
]
},
{
Expand Down Expand Up @@ -216,7 +214,7 @@
"outputs": [],
"source": [
"# Display the products, if you want\n",
"data_products_nodust.show_in_notebook()"
"data_products_nodust"
]
},
{
Expand All @@ -235,8 +233,8 @@
"outputs": [],
"source": [
"filtered_products_nodust = Observations.filter_products(data_products_nodust,\n",
" productType='SCIENCE',\n",
" extension = '.fits')\n",
" productType='SCIENCE',\n",
" extension='.fits')\n",
"len(filtered_products_nodust)"
]
},
Expand All @@ -248,7 +246,7 @@
"outputs": [],
"source": [
"# Display the results, if you want\n",
"filtered_products_nodust.show_in_notebook()"
"filtered_products_nodust"
]
},
{
Expand Down Expand Up @@ -286,18 +284,18 @@
"outputs": [],
"source": [
"obs_table_dusty = Observations.query_criteria(obs_collection=\"IUE\",\n",
" objectname=target_dusty,\n",
" radius = \"0m\",\n",
" proposal_pi=\"Prevot\") # We specify the PI since this search returns more results\n",
" objectname=target_dusty,\n",
" radius=\"0m\",\n",
" proposal_pi=\"Prevot\") # We specify the PI since this search returns more results\n",
"\n",
"\n",
"data_products_dusty = Observations.get_product_list(obs_table_dusty)\n",
"\n",
"# Note that you can skip the 'filter products' step\n",
"# Instead, you can pass the filters directly to 'download_products'\n",
"manifest_dusty = Observations.download_products(data_products_dusty,\n",
" productType='SCIENCE',\n",
" extension = \".fits\")"
" productType='SCIENCE',\n",
" extension=\".fits\")"
]
},
{
Expand Down Expand Up @@ -356,9 +354,7 @@
"cell_type": "code",
"execution_count": null,
"id": "897a2252",
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"with fits.open(lw_dusty) as hdulist: \n",
Expand Down Expand Up @@ -417,7 +413,7 @@
" \n",
" # Extract our desired data from the corresponding columns\n",
" wav = spectrum[0][0] # wavelength, angstrom, A\n",
" flux = spectrum [0][1] # flux, ergs/cm2/sec/A\n",
" flux = spectrum[0][1] # flux, ergs/cm2/sec/A\n",
"\n",
" return wav, flux"
]
Expand All @@ -434,9 +430,7 @@
"cell_type": "code",
"execution_count": null,
"id": "781f9315",
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"# Let's run our helper function on our data\n",
Expand Down Expand Up @@ -511,30 +505,31 @@
"metadata": {},
"outputs": [],
"source": [
"# Create a helper function to plot the data. We want to plot inverse wavelength against log of flux\n",
"def Plot(wav, flux, style, lbl):\n",
" plt.plot(10**4/wav, np.log10(flux), style, label=lbl)\n",
"\n",
"\n",
"# Set up the plot size, labels, units\n",
"fig = plt.figure()\n",
"ax = plt.subplot(111)\n",
"ax.set_xlabel('1/$\\lambda$ ($\\mu m^{-1}$)')\n",
"ax.set_xlabel(r'1/$\\lambda$ ($\\mu m^{-1}$)')\n",
"ax.set_ylabel(r'log(Flux (ergs $cm^{-2}$ $s^{-1}$ $\\AA^{-1}$))')\n",
"ax.set_xlim([3,8])\n",
"ax.set_xlim([3, 8])\n",
"ax.set_ylim([-13.6, -11.5])\n",
"\n",
"# Create a helper function to plot the data. We want to plot inverse wavelength against log of flux\n",
"def Plot(wav, flux, style, lbl):\n",
" plt.plot(10**4/wav, np.log10(flux), style, label=lbl)\n",
"\n",
"# Call the helper function four times: for long/short wavelengths of both targets\n",
"Plot(wav_lw_dusty, flux_lw_dusty, 'r:', 'lw_dusty')\n",
"Plot(wav_sw_dusty, flux_sw_dusty, 'r', 'sw_dusty')\n",
"Plot(wav_lw_nodust, flux_lw_nodust, 'b:', 'lw_nodust')\n",
"Plot(wav_sw_nodust, flux_sw_nodust, 'b', 'sw_nodust')\n",
"\n",
"# Add some labels to our plot to clarify which spectrum is which\n",
"plt.text(6.7, -13.4, target_dusty, fontsize = 11, color='r')\n",
"plt.text(6.1, -12.6, target_nodust, fontsize = 11, color='b')\n",
"plt.text(6.7, -13.4, target_dusty, fontsize=11, color='r')\n",
"plt.text(6.1, -12.6, target_nodust, fontsize=11, color='b')\n",
"\n",
"# Create the legend and show our plot\n",
"plt.legend(loc='best',frameon=False)\n",
"plt.legend(loc='best', frameon=False)\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -564,7 +559,7 @@
"outputs": [],
"source": [
"# Request the B and V magnitudes\n",
"Simbad.add_votable_fields('flux(B)','flux(V)')\n",
"Simbad.add_votable_fields('flux(B)', 'flux(V)')\n",
"\n",
"# Query for dusty star, in our case AvZ 456\n",
"table_dusty = Simbad.query_object(target_dusty)"
Expand All @@ -578,7 +573,7 @@
"outputs": [],
"source": [
"# Examine the data, if you want\n",
"table_dusty.show_in_notebook()"
"table_dusty"
]
},
{
Expand Down Expand Up @@ -615,11 +610,11 @@
"outputs": [],
"source": [
"# Extract these values from the table\n",
"V_dusty = table_dusty['FLUX_V'][0]\n",
"B_dusty = table_dusty['FLUX_B'][0]\n",
"V_dusty = table_dusty['V'][0]\n",
"B_dusty = table_dusty['B'][0]\n",
"\n",
"V_nodust = table_nodust['FLUX_V'][0]\n",
"B_nodust = table_nodust['FLUX_B'][0]\n",
"V_nodust = table_nodust['V'][0]\n",
"B_nodust = table_nodust['B'][0]\n",
"\n",
"# Plug into the formula\n",
"EBV = (B_dusty-V_dusty)-(B_nodust-V_nodust)\n",
Expand Down Expand Up @@ -647,17 +642,17 @@
"metadata": {},
"outputs": [],
"source": [
"V_rat = V_dusty/V_nodust\n",
"\n",
"# Another helper function to create our plots, and save the output data for further analysis\n",
"def Extinction(wav, flux1, flux2):\n",
" V_rat = V_dusty/V_nodust\n",
" flux_rat = flux1/flux2\n",
" # Calcuating extinction from the formula \n",
" ext = np.log(V_rat/flux_rat)/EBV\n",
" inv_wav= 10**4/wav\n",
" inv_wav = 10**4/wav\n",
" plt.plot(inv_wav, ext, 'o', markersize=2)\n",
" return inv_wav, ext \n",
"\n",
"\n",
"# Create the figure, then use the helper function to create the plots and save the data\n",
"plt.figure()\n",
"s_inv_wav, s_ext = Extinction(wav_sw_dusty, flux_sw_dusty, flux_sw_nodust)\n",
Expand Down Expand Up @@ -778,7 +773,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "myenv",
"language": "python",
"name": "python3"
},
Expand All @@ -792,7 +787,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.10.16"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
astropy >= 5.3.3
astroquery >= 0.4.6
matplotlib >= 3.6.2
numpy >= 1.23.5
numpy >= 1.23.5, < 2.0.0
scipy >= 1.10.1

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@
"obs_list = Observations.query_criteria(proposal_id=2733)\n",
"\n",
"# We can chooose the columns we want to display in our table\n",
"disp_col = ['dataproduct_type','calib_level','obs_id',\n",
" 'target_name','filters','proposal_pi', 'obs_collection']\n",
"obs_list[disp_col].show_in_notebook()"
"disp_col = ['dataproduct_type', 'calib_level', 'obs_id',\n",
" 'target_name', 'filters', 'proposal_pi', 'obs_collection']\n",
"obs_list[disp_col]"
]
},
{
Expand Down Expand Up @@ -234,8 +234,8 @@
"filtered_prod = Observations.filter_products(data_products, calib_level=[2], productType=\"SCIENCE\")\n",
"\n",
"# Again, we choose columns of interest for convenience\n",
"disp_col = ['obsID','dataproduct_type','productFilename','size','calib_level']\n",
"filtered_prod[disp_col].show_in_notebook(display_length=10)"
"disp_col = ['obsID', 'dataproduct_type', 'productFilename', 'size', 'calib_level']\n",
"filtered_prod[disp_col][:10]"
]
},
{
Expand Down Expand Up @@ -374,7 +374,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "myenv",
"language": "python",
"name": "python3"
},
Expand All @@ -388,7 +388,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.10.16"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 7e51c5c

Please sign in to comment.