Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 59b490c

Browse files
Merge pull request #8 from rubin-dp0/tickets/PREOPS-532
fixed schema instructions
2 parents 6513d48 + c36f036 commit 59b490c

1 file changed

Lines changed: 72 additions & 2 deletions

File tree

04_Intro_to_Butler.ipynb

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,7 @@
569569
"\n",
570570
"The TAP service is the recommended way to retrieve DP0.1 catalog data for a notebook, and there are several other tutuorials that demonstrate how to use the TAP service.\n",
571571
"\n",
572-
"But if Butler access to catalog data is needed, start by retrieving only the schema of a Butler catalog.\n",
573-
"Unlike with TAP schema (as in the first tutorial notebook), the Butler schema do not come with embedded column descriptions. Refer to the DP0.1 Data Products Definitions Document (DPDD) at [dp0-1.lsst.io](http://dp0-1.lsst.io) to find out more about the columns."
572+
"But if Butler access to catalog data is needed, an easy way to start is by retrieving only the schema data set for a Butler catalog, which can be done without specifying the ``dataId``. "
574573
]
575574
},
576575
{
@@ -583,6 +582,77 @@
583582
"schema_coadd_src.asAstropy()"
584583
]
585584
},
585+
{
586+
"cell_type": "markdown",
587+
"metadata": {},
588+
"source": [
589+
"Each of the following lines will print the schema to the screen in different ways."
590+
]
591+
},
592+
{
593+
"cell_type": "code",
594+
"execution_count": null,
595+
"metadata": {},
596+
"outputs": [],
597+
"source": [
598+
"# schema_coadd_src.schema\n",
599+
"# schema_coadd_src.schema.getNames()\n",
600+
"# schema_coadd_src.schema.getOrderedNames()\n",
601+
"print('Number of columns in this table = ', len(schema_coadd_src.schema.getNames()) )"
602+
]
603+
},
604+
{
605+
"cell_type": "markdown",
606+
"metadata": {},
607+
"source": [
608+
"Perhaps you want to search for all schema elements that contain the term 'psf'."
609+
]
610+
},
611+
{
612+
"cell_type": "code",
613+
"execution_count": null,
614+
"metadata": {},
615+
"outputs": [],
616+
"source": [
617+
"# Define an array that is all of the column names\n",
618+
"all_names = schema_coadd_src.schema.getOrderedNames()\n",
619+
"\n",
620+
"# Loop over the names and look for the term 'psf'\n",
621+
"for i,name in enumerate(all_names):\n",
622+
" if name.find('psf') >= 0:\n",
623+
" print( i, name )\n",
624+
"del all_names"
625+
]
626+
},
627+
{
628+
"cell_type": "markdown",
629+
"metadata": {},
630+
"source": [
631+
"Probably you will want to know more about the values in these columns. You can do that by printing the documentation string in the schema."
632+
]
633+
},
634+
{
635+
"cell_type": "code",
636+
"execution_count": null,
637+
"metadata": {},
638+
"outputs": [],
639+
"source": [
640+
"# Turn the schema into a python dictionary, to be able to call a column by name\n",
641+
"schema_dict = schema_coadd_src.schema.extract('*')\n",
642+
"\n",
643+
"# Print the associated docstring for each of the named columns of interest\n",
644+
"for name in ['base_SdssShape_psf_xx','base_SdssShape_psf_yy','base_SdssShape_psf_xy']:\n",
645+
" doc = schema_dict[name].getField().getDoc()\n",
646+
" print(name, ' = ', doc)"
647+
]
648+
},
649+
{
650+
"cell_type": "markdown",
651+
"metadata": {},
652+
"source": [
653+
"Refer to the DP0.1 Data Products Definitions Document (DPDD) at [dp0-1.lsst.io](http://dp0-1.lsst.io) to find out more about the columns."
654+
]
655+
},
586656
{
587657
"cell_type": "markdown",
588658
"metadata": {},

0 commit comments

Comments
 (0)