Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HSC table and columns names in UCD notebook #166

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions content/reference_notebooks/ucds_unified_content_descriptors.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.14.4
jupytext_version: 1.16.2
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
language_info:
Expand All @@ -19,7 +19,7 @@ language_info:
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.7.10
version: 3.11.9
---

# UCDs (Unified Content Descriptors)
Expand Down Expand Up @@ -65,21 +65,21 @@ for t in tables:
Let's look at the first 10 columns of the DetailedCatalog table. Again, note that calling the columns attribute sends another query to the service to ask for the columns.

```{code-cell} ipython3
columns=tables['dbo.DetailedCatalog'].columns
columns=tables['dbo.detailedcatalog'].columns
for c in columns:
print(f'{f"{c.name} [{c.ucd}]":30s} - {c.description}')
```

The PyVO method to get the columns will automatically fetch all the meta-data about those columns. It's up to the service provider to set them correctly, of course, but in this case, we see that the column named "MatchRA" is identified with the UCD "pos.eq.ra".
The PyVO method to get the columns will automatically fetch all the meta-data about those columns. It's up to the service provider to set them correctly, of course, but in this case, we see that the column named "matchra" is identified with the UCD "pos.eq.ra".

So if we did not know the exact name used in HSCv3 for the RA, we could do something like this looking for the string "RA":
So if we did not know the exact name used in HSCv3 for the RA, we could do something like this looking for the string "ra":

```{code-cell} ipython3
ra_name=[c.name for c in columns if 'RA' in c.name or "ascension" in c.name.lower()]
ra_name=[c.name for c in columns if 'ra' in c.name.lower() or "ascension" in c.name.lower()]
print(ra_name)
```

But a more general approach is to check for the correct UCD. It also has the further advantage that it can be used to label columns that should be used for certain purposes when there are multiple possibilities. For instance, this table has MatchRA and SourceRA. Let's check the UCD:
Since that guessing doesn't give a unique answer, the more general and reliable approach is to check for the correct UCD. It also has the further advantage that it can be used to label columns that should be used for certain purposes when there are multiple possibilities. For instance, this table has MatchRA and SourceRA. Let's check the UCD:

(Note that the UCD is not required. If it isn't there, you get a None type, so code the check carefully)

Expand Down Expand Up @@ -159,7 +159,7 @@ for tname,results in collection.items():
Lastly, if you have a table of results from a TAP query (and if that service includes the UCDs), then you can get data based on UCDs with the getbyucd() method, which simply gets the corresponding element using fieldname_with_ucd():

```{code-cell} ipython3
results=hsc.service.search("select top 10 * from dbo.DetailedCatalog")
results=hsc.service.search("select top 10 * from dbo.detailedcatalog")
[r.getbyucd('phot.mag') for r in results]
```

Expand Down
2 changes: 1 addition & 1 deletion doc-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Doc and testing requirements
sphinx<5
sphinx
myst-nb>=0.14
sphinx-book-theme
sphinx-copybutton
Expand Down