Skip to content

Conversation

@miguelglezb
Copy link
Collaborator

Refactored tutorials made to follow refactored pykoala commits from Dec 2024 to April 2025. This MR includes preliminary version of cubing tutorial

@@ -0,0 +1,286 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tutorial for cubing should go on the 2-science-data/ dir

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps there should be two (or more) tutorials: one for basic stuff (explaining how to read a datacube, what are wavelength, intensity, and variance, how to make simple plots...), and another one on creating a cube from a set of RSS, which may contain advanced stuff such as registration or ADR.

In any case, why do we use a standard star instead of a galaxy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PabloCorcho noted.

@paranoya is there a fits file in the repository data that contains a galaxy?

Copy link
Member

@PabloCorcho PabloCorcho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot Miguel!!

Comment on lines +215 to +234
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"datacube_shape = (std_star_rss[0].wavelength.size, 40, 60)\n",
"ref_position = (std_star_rss[0].wavelength[0], np.mean(std_star_rss[0].info['fib_ra']), np.mean(std_star_rss[0].info['fib_dec'])) # (deg, deg)\n",
"spatial_pixel_size = 1.0 << u.arcsec\n",
"spectral_pixel_size = std_star_rss[0].wavelength[1] - std_star_rss[0].wavelength[0] # (angstrom)\n",
"\n",
"print(f\"Creating a WCS with\\n position: {ref_position}\\n Spatial pixel size: {spatial_pixel_size}\\n Spectral pixel size: {spectral_pixel_size}\")\n",
"\n",
"wcs = build_wcs(datacube_shape=datacube_shape,\n",
" reference_position=ref_position,\n",
" spatial_pix_size=spatial_pixel_size,\n",
" spectra_pix_size=spectral_pixel_size,\n",
" )"
]
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated cell?

"cell_type": "markdown",
"metadata": {},
"source": [
"#### `rss_intensity`"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth explaining the meaning of this variable

Comment on lines +236 to +247
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"pos_com = find_centroid_in_dc(cube, centroider='com', com_power=1.)\n",
"pos_com_3 = find_centroid_in_dc(cube, centroider='com', com_power=3.)\n",
"pos_gauss = find_centroid_in_dc(cube, centroider='gauss')"
]
},
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a new section where the use of this method is explained?

"source": [
"interpolator = CubeInterpolator(rss_set=std_star_rss)\n",
"cube = interpolator.build_cube()\n",
"white_image = np.nanmean(cube.intensity, axis=0)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since cubes have a method cube.get_white_image it might be worth using that here instead

"metadata": {},
"outputs": [],
"source": [
"print(f\"Center of mass of the data cube: \\n\\n {cube.get_centre_of_mass()}\")"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I would explain that the com is per wavelength unit

"cell_type": "markdown",
"metadata": {},
"source": [
"With `science_fibres` we can find the indexes of the fibres with non-bad pixels:"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Science fibres are those that target the object of interest, sky fibres are the ones located in sky blanks to estimate the contribution of the sky emission. In the case of KOALA, there's no default sky fibres.

Comment on lines +410 to +421
"Now we select the wavelenght range. **Make sure to use astropy quantities and not simple float values.** \n",
"\n",
"In this case we will use the same elements of the RSS wavelengh data to define the range."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rss_sample.get_integrated_fibres(wavelength_range=[6000,7000])"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You say the user has to make sure of using quantities, but then you pass a list of ints (which also works because we do not enforce the use of units here)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this file and let the user create it on the fly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the output be .gitignore'd?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this use for testing?

"cell_type": "markdown",
"metadata": {},
"source": [
"RSS metada is stored as a `DataContainerHistory` object"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add link to the relevant tutorial?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants