|
9 | 9 | "\n", |
10 | 10 | "# Photo-z Server - Tutorial Notebook\n", |
11 | 11 | "\n", |
12 | | - "Contact author: [Julia Gschwend](mailto:[email protected])\n", |
| 12 | + "Contact author: Julia Gschwend ([[email protected]](mailto:[email protected]))\n", |
13 | 13 | "\n", |
14 | | - "Last verified run: 2024-Jun-04<br>" |
| 14 | + "Last verified run: 2024-Jun-25<br>" |
15 | 15 | ] |
16 | 16 | }, |
17 | 17 | { |
|
29 | 29 | " - [How to upload a data product to the PZ Server](#how-to-upload-a-data-product-to-the-pz-server)\n", |
30 | 30 | " - [How to download a data product from the PZ Server](#how-to-download-a-data-product-from-the-pz-server)\n", |
31 | 31 | "- PZ Server API (Python library pzserver)\n", |
| 32 | + "- PZ Server API (Python library pzserver)\n", |
32 | 33 | " - [How to get general info from PZ Server](#how-to-get-general-info-from-pz-server)\n", |
33 | 34 | " - [How to display the metadata of a data product](#how-to-display-the-metadata-of-a-data-product)\n", |
34 | 35 | " - [How to download data products as .zip files](#how-to-download-data-products-as-zip-files) \n", |
|
63 | 64 | "The Photo-z (PZ) Server is an online service available for the LSST Community to host and share lightweight photo-z related data products. The upload and download of data and metadata can be done at the website [pz-server.linea.org.br](https://pz-server.linea.org.br/) (during the development phase, a test environment is available at [pz-server-dev.linea.org.br](https://pz-server-dev.linea.org.br/)). There, you will find two separate pages containing a list of data products each: one for LSST Data Management's oficial data products, and other for user-generated data products. **The registered data products can also be accessed directly from Python code using the PZ Server's data access API, as demonstrated below.**\n", |
64 | 65 | "\n", |
65 | 66 | "The PZ Server is developed and delivered as part of the in-kind contribution program BRA-LIN, from LIneA to the Rubin Observatory's LSST. The service is hosted in the Brazilian IDAC, not directly connected to the [Rubin Science Platform (RSP)](https://data.lsst.cloud/). However, it requires RSP credentials for user's authentication. For a comprehensive documentation about the PZ Server, please visit the [PZ Server's documentation page](https://linea-it.github.io/pz-lsst-inkind-doc/). There, you will find also an overview of all LIneA's contributions related to Photo-zs. The internal documentation of the API functions is available on the [API's documentation page](https://linea-it.github.io/pzserver/html/index.html). " |
| 67 | + "The PZ Server is developed and delivered as part of the in-kind contribution program BRA-LIN, from LIneA to the Rubin Observatory's LSST. The service is hosted in the Brazilian IDAC, not directly connected to the [Rubin Science Platform (RSP)](https://data.lsst.cloud/). However, it requires RSP credentials for user's authentication. For a comprehensive documentation about the PZ Server, please visit the [PZ Server's documentation page](https://linea-it.github.io/pz-lsst-inkind-doc/). There, you will find also an overview of all LIneA's contributions related to Photo-zs. The internal documentation of the API functions is available on the [API's documentation page](https://linea-it.github.io/pzserver/html/index.html). " |
66 | 68 | ] |
67 | 69 | }, |
68 | 70 | { |
69 | 71 | "cell_type": "markdown", |
70 | 72 | "metadata": {}, |
71 | 73 | "source": [ |
| 74 | + "## How to upload a data product on the PZ Server website\n", |
72 | 75 | "## How to upload a data product on the PZ Server website\n", |
73 | 76 | "\n", |
74 | 77 | "To upload a data product, click on the button **NEW PRODUCT** on the top left of the **User-generated Data Products** page and fill in the Upload Form with relevant metadata. Alternatively, the user can upload files to the PZ Server programatically via the `pzserver` Python Library (described below). \n", |
| 78 | + "To upload a data product, click on the button **NEW PRODUCT** on the top left of the **User-generated Data Products** page and fill in the Upload Form with relevant metadata. Alternatively, the user can upload files to the PZ Server programatically via the `pzserver` Python Library (described below). \n", |
75 | 79 | "\n", |
76 | 80 | "The photo-z-related products are organized into four categories (product types):\n", |
77 | 81 | "\n", |
78 | 82 | "- **Spec-z Catalog:** Catalog of spectroscopic redshifts and positions (usually equatorial coordinates).\n", |
79 | 83 | "- **Training Set:** Training set for photo-z algorithms (tabular data). It usually contains magnitudes, errors, and true redshifts.\n", |
80 | 84 | "- **Photo-z Validation Results:** Results of a photo-z validation procedure (free format). Usually contains photo-z estimates (single estimates and/or pdf) of a validation set, photo-z validation metrics, validation plots, etc.\n", |
81 | 85 | "- **Photo-z Table:** Results of a photo-z estimation procedure. Ideally in the same format as the photo-z tables delivered by the DM as part of the LSST data releases. If the data is larger than the file upload limit (200MB), the product entry stores only the metadata (and instructions on accessing the data should be provided in the description field). " |
| 86 | + "- **Photo-z Table:** Results of a photo-z estimation procedure. Ideally in the same format as the photo-z tables delivered by the DM as part of the LSST data releases. If the data is larger than the file upload limit (200MB), the product entry stores only the metadata (and instructions on accessing the data should be provided in the description field). " |
82 | 87 | ] |
83 | 88 | }, |
84 | 89 | { |
85 | 90 | "cell_type": "markdown", |
86 | 91 | "metadata": {}, |
87 | 92 | "source": [ |
| 93 | + "## How to download a data product from the PZ Server website\n", |
88 | 94 | "## How to download a data product from the PZ Server website\n", |
89 | 95 | "\n", |
90 | 96 | "To download a data product available on the Photo-z Server, go to one of the two pages by clicking on the card \"LSST PZ Data Products\" (for official products released by LSST DM Team) or \"User-generated Data Products\" (for products uploaded by the members of LSST community. The download button is on the left side of each data product (each row of the list). " |
|
95 | 101 | "metadata": {}, |
96 | 102 | "source": [ |
97 | 103 | "# The PZ Server API (Python library `pzserver`)" |
| 104 | + "# The PZ Server API (Python library `pzserver`)" |
98 | 105 | ] |
99 | 106 | }, |
100 | 107 | { |
|
171 | 178 | "outputs": [], |
172 | 179 | "source": [ |
173 | 180 | "# pz_server = PzServer(token=\"<your token>\", host=\"pz-dev\") # \"pz-dev\" is the temporary host for test phase " |
| 181 | + "# pz_server = PzServer(token=\"<your token>\", host=\"pz-dev\") # \"pz-dev\" is the temporary host for test phase " |
| 182 | + ] |
| 183 | + }, |
| 184 | + { |
| 185 | + "cell_type": "markdown", |
| 186 | + "metadata": {}, |
| 187 | + "source": [ |
| 188 | + "For convenience, the token can be saved into a file named as `token.txt` (which is already listed in the .gitignore file in this repository). " |
| 189 | + ] |
| 190 | + }, |
| 191 | + { |
| 192 | + "cell_type": "code", |
| 193 | + "execution_count": null, |
| 194 | + "metadata": {}, |
| 195 | + "outputs": [], |
| 196 | + "source": [ |
| 197 | + "with open('token.txt', 'r') as file:\n", |
| 198 | + " token = file.read()\n", |
| 199 | + "pz_server = PzServer(token=token, host=\"pz-dev\") # \"pz-dev\" is the temporary host for test phase " |
174 | 200 | ] |
175 | 201 | }, |
176 | 202 | { |
|
202 | 228 | "cell_type": "markdown", |
203 | 229 | "metadata": {}, |
204 | 230 | "source": [ |
| 231 | + "The object `pz_server` just created above can provide access to data and metadata stored in the PZ Server. It also brings useful methods for users to navigate through the available contents. The methods with the preffix `get_` return the result of a query on the PZ Server database as a Python dictionary, and are most useful to be used programatically (see detaials on the [API documentation page](https://linea-it.github.io/pzserver/html/index.html)). Alternatively, those with the preffix `display_` show the results as a styled [_Pandas DataFrames_](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html), optimized for Jupyter Notebook (note: column names might change in the display version). For instance:\n", |
205 | 232 | "The object `pz_server` just created above can provide access to data and metadata stored in the PZ Server. It also brings useful methods for users to navigate through the available contents. The methods with the preffix `get_` return the result of a query on the PZ Server database as a Python dictionary, and are most useful to be used programatically (see detaials on the [API documentation page](https://linea-it.github.io/pzserver/html/index.html)). Alternatively, those with the preffix `display_` show the results as a styled [_Pandas DataFrames_](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html), optimized for Jupyter Notebook (note: column names might change in the display version). For instance:\n", |
206 | 233 | "\n", |
207 | 234 | "Display the list of product types supported with a short description;" |
|
345 | 372 | "## How to upload a data product to via Python API (alternative method) " |
346 | 373 | ] |
347 | 374 | }, |
| 375 | + { |
| 376 | + "cell_type": "markdown", |
| 377 | + "metadata": {}, |
| 378 | + "source": [ |
| 379 | + "The default method to upload a data product to the PZ Server is the upload tool on PZ Server website, as shown above. Alternatively, data products can be sent to the host service using the `pzserver` Python library. \n", |
| 380 | + "## How to upload a data product to via Python API (alternative method) " |
| 381 | + ] |
| 382 | + }, |
348 | 383 | { |
349 | 384 | "cell_type": "markdown", |
350 | 385 | "metadata": {}, |
|
416 | 451 | "upload.product_id" |
417 | 452 | ] |
418 | 453 | }, |
| 454 | + { |
| 455 | + "cell_type": "markdown", |
| 456 | + "metadata": {}, |
| 457 | + "source": [ |
| 458 | + "First, prepare a dictionary with the relevant information about your data product: " |
| 459 | + ] |
| 460 | + }, |
| 461 | + { |
| 462 | + "cell_type": "code", |
| 463 | + "execution_count": null, |
| 464 | + "metadata": {}, |
| 465 | + "outputs": [], |
| 466 | + "source": [ |
| 467 | + "data_to_upload = {\n", |
| 468 | + " \"name\":\"upload example 1\",\n", |
| 469 | + " \"product_type\": \"specz_catalog\", \n", |
| 470 | + " \"release\": None, # LSST release, use None if not LSST data \n", |
| 471 | + " \"main_file\": \"example.csv\", # full path \n", |
| 472 | + " \"auxiliary_files\": [\"example.html\", \"example.ipynb\"] # full path\n", |
| 473 | + "}" |
| 474 | + ] |
| 475 | + }, |
| 476 | + { |
| 477 | + "cell_type": "code", |
| 478 | + "execution_count": null, |
| 479 | + "metadata": {}, |
| 480 | + "outputs": [], |
| 481 | + "source": [ |
| 482 | + "upload = pz_server.upload(**data_to_upload) " |
| 483 | + ] |
| 484 | + }, |
| 485 | + { |
| 486 | + "cell_type": "markdown", |
| 487 | + "metadata": {}, |
| 488 | + "source": [] |
| 489 | + }, |
| 490 | + { |
| 491 | + "cell_type": "code", |
| 492 | + "execution_count": null, |
| 493 | + "metadata": {}, |
| 494 | + "outputs": [], |
| 495 | + "source": [ |
| 496 | + "columns_dict = {\"ID\" : \"ID\", \n", |
| 497 | + " \"RA\" : \"RA\", \n", |
| 498 | + " \"Dec\": \"DEC\",\n", |
| 499 | + " \"z\" : \"Z\",\n", |
| 500 | + " \"z_err\" : \"ERR_Z\",\n", |
| 501 | + " \"z_flag\": \"FLAG_DES\" \n", |
| 502 | + " }" |
| 503 | + ] |
| 504 | + }, |
| 505 | + { |
| 506 | + "cell_type": "code", |
| 507 | + "execution_count": null, |
| 508 | + "metadata": {}, |
| 509 | + "outputs": [], |
| 510 | + "source": [ |
| 511 | + "upload.make_columns_association(columns_dict) " |
| 512 | + ] |
| 513 | + }, |
| 514 | + { |
| 515 | + "cell_type": "code", |
| 516 | + "execution_count": null, |
| 517 | + "metadata": {}, |
| 518 | + "outputs": [], |
| 519 | + "source": [ |
| 520 | + "upload.product_id" |
| 521 | + ] |
| 522 | + }, |
419 | 523 | { |
420 | 524 | "cell_type": "markdown", |
421 | 525 | "metadata": {}, |
|
427 | 531 | "cell_type": "markdown", |
428 | 532 | "metadata": {}, |
429 | 533 | "source": [ |
| 534 | + "The metadata of a given data product is the information provided by the user on the upload form. This information is attached to the data product contents and is available for consulting on the PZ Server page or using this Python API (`pzserver`). \n", |
430 | 535 | "The metadata of a given data product is the information provided by the user on the upload form. This information is attached to the data product contents and is available for consulting on the PZ Server page or using this Python API (`pzserver`). \n", |
431 | 536 | "\n", |
432 | 537 | "All data products stored on PZ Server are identified by a unique **id** number or an unique name, a _string_ called **internal_name**, which is created automatically at the moment of the upload by concatenating the product **id** to the name given by its owner (replacing blank spaces by \"_\", lowering cases, and removing special characters). " |
|
562 | 667 | "metadata": {}, |
563 | 668 | "outputs": [], |
564 | 669 | "source": [ |
565 | | - "catalog.data" |
| 670 | + "catalog.data\n" |
566 | 671 | ] |
567 | 672 | }, |
568 | 673 | { |
|
981 | 1086 | "\n", |
982 | 1087 | "Is something important missing? [Click here to open an issue in the PZ Server library repository on GitHub](https://github.com/linea-it/pzserver/issues/new). " |
983 | 1088 | ] |
984 | | - }, |
985 | | - { |
986 | | - "cell_type": "code", |
987 | | - "execution_count": null, |
988 | | - "metadata": {}, |
989 | | - "outputs": [], |
990 | | - "source": [] |
991 | | - }, |
992 | | - { |
993 | | - "cell_type": "code", |
994 | | - "execution_count": null, |
995 | | - "metadata": {}, |
996 | | - "outputs": [], |
997 | | - "source": [] |
998 | 1089 | } |
999 | 1090 | ], |
1000 | 1091 | "metadata": { |
|
1014 | 1105 | "nbconvert_exporter": "python", |
1015 | 1106 | "pygments_lexer": "ipython3", |
1016 | 1107 | "version": "3.10.10" |
| 1108 | + "version": "3.10.10" |
1017 | 1109 | }, |
1018 | 1110 | "nbsphinx": { |
1019 | 1111 | "execute": "never" |
|
0 commit comments