You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 2. Search for the spectrum of a specific galaxy in the 1D spectra table
82
+
86
83
```{code-cell} ipython3
87
-
## Change the settings so we can see all the columns in the dataframe and the full column width
88
-
## (to see the full long URL)
89
-
pd.set_option('display.max_columns', None)
90
-
pd.set_option('display.max_colwidth', None)
84
+
obj_id = 2689918641685825137
85
+
```
86
+
87
+
We will use TAP and an ASQL query to find the spectral data for our galaxy. (ADQL is the [IVOA Astronomical Data Query Language](https://www.ivoa.net/documents/latest/ADQL.html) and is based on SQL.)
91
88
89
+
```{code-cell} ipython3
90
+
adql_object = f"SELECT * FROM {table_1dspectra} WHERE objectid = {obj_id}"
92
91
93
-
## Can use the following lines to reset the max columns and column width of pandas
94
-
# pd.reset_option('display.max_columns')
95
-
# pd.reset_option('display.max_colwidth')
92
+
# Pull the data on this particular galaxy
93
+
result = Irsa.query_tap(adql_object).to_table()
96
94
```
97
95
98
-
## 2. Search for the spectrum of a specific galaxy in the 1D spectra table
## 3. Read in the spectrum for only our specific object
102
104
103
-
## Pull the data on these objects
104
-
adql_object = f"SELECT * \
105
-
FROM {table_1dspectra} \
106
-
WHERE objectid = {obj_id} \
107
-
AND uri IS NOT NULL "
105
+
Currently IRSA has the spectra stored in very large files containing multiple (14220) extensions with spectra of many targets within one tile. You can choose to read in the big file below to see what it looks like (takes a few mins to load) or skip this step and just read in the specific extension we want for the 1D spectra (recommended).
108
106
109
-
## Pull the data on this particular galaxy
110
-
result2 = service.search(adql_object)
111
-
df2=result2.to_table().to_pandas()
112
-
df2
107
+
```{code-cell} ipython3
108
+
# hdul = fits.open(file_uri)
109
+
# hdul.info()
113
110
```
114
111
115
-
### Create the full filename/url
112
+
Open the large FITS file without loading it entirely into memory, pulling out just the extension we want for the 1D spectra of our object
## 3. Read in the spectrum using the file_url and the extension just for this object
125
-
126
-
Currently IRSA has the spectra stored in very large files containing multiple (14220) extensions with spectra of many targets within one tile. You can choose to read in the big file below to see what it looks like (takes a few mins to load) or skip this step and just read in the specific extension we want for the 1D spectra (recommended).
121
+
```{code-cell} ipython3
122
+
spectra
123
+
```
127
124
128
125
```{code-cell} ipython3
129
-
#### Code to read in the large file with many extensions and spectra from a tile
130
-
#### Currently commented out
126
+
spec_header
127
+
```
131
128
132
-
# ## Complete file url with the irsa url at the start
133
-
# url = file_url
134
-
# response = requests.get(url)
129
+
## 4. Plot the image of the extracted spectrum
135
130
136
-
# hdul = fits.open(BytesIO(response.content)) # Open FITS file from memory
137
-
# hdul.info() # Show file info
131
+
```{tip}
132
+
As we use astropy.visualization's ``quantity_support``, matplotlib automatically picks up the axis units from the quantitites we plot.
138
133
```
139
134
140
-
### Open the large FITS file without loading it entirely into memory, pulling out just the extension we want for the 1D spectra of our object
141
-
142
135
```{code-cell} ipython3
143
-
response = requests.get(file_url)
136
+
quantity_support()
137
+
```
138
+
139
+
```{note}
140
+
The 1D combined spectra table contains 6 columns, below are a few highlights:
144
141
145
-
with fits.open(BytesIO(response.content), memmap=True) as hdul:
146
-
hdu = hdul[df2['hdu'].iloc[0]]
147
-
dat = Table.read(hdu, format='fits', hdu=1)
148
-
df_obj_irsa = dat.to_pandas()
142
+
- WAVELENGTH is in Angstroms by default
143
+
- SIGNAL is the flux and should be multiplied by the FSCALE factor in the header
144
+
- MASK values can be used to determine which flux bins to discard. MASK = odd and MASK >=64 means the flux bins not be used.
0 commit comments