transientNamer.search module

Search the Transient Name Server with various search constraints

Author

David Young

class search(log, ra='', dec='', radiusArcsec='', name='', discInLastDays='', settings=False, comments=False)[source]

Bases: object

Search the Transient Name Server with various search constraints

Key Arguments

  • log – logger

  • settings – the settings dictionary

  • ra – RA of the location being checked

  • dec – DEC of the location being searched

  • radiusArcsec - the radius of the conesearch to perform against the TNS

  • name – name of the object to search the TNS for

  • discInLastDays – search the TNS for transient reported in the last X days

  • comments – print the comments from the TNS, note these can be long making table outputs somewhat unreadable. Default False

Usage

To initiate a search object to search the TNS via an object name (either TNS or survey names accepted):

from transientNamer import search
tns = search(
    log=log,
    name="Gaia16bbi"
)

or for a conesearch use something similar to:

from transientNamer import search
tns = search(
    log=log,
    ra="06:50:36.74",
    dec="+31:06:44.7",
    radiusArcsec=5
)

Note the search method can accept coordinates in sexagesimal or decimal defree formats.

To list all new objects reported in the last three weeks, then use:

from transientNamer import search
tns = search(
    log=log,
    discInLastDays=21
)
property sources[source]

The results of the search returned as a python list of dictionaries

Usage

sources = tns.sources
property spectra[source]

The associated source spectral data

Usage

sourceSpectra = tns.spectra
property files[source]

The associated source files

Usage

sourceFiles = tns.files
property photometry[source]

The associated source photometry

Usage

sourcePhotometry = tns.photometry
property url[source]

The generated URL used for searching of the TNS

Usage

searchURL = tns.url
csv(dirPath=None)[source]

Render the results in csv format

Key Arguments

  • dirPath – the path to the directory to save the rendered results to. Default None

Return

  • csvSources – the top-level transient data

  • csvPhot – all photometry associated with the transients

  • csvSpec – all spectral data associated with the transients

  • csvFiles – all files associated with the matched transients found on the tns

Usage

To render the results in csv format:

csvSources, csvPhot, csvSpec, csvFiles  = tns.csv()
print(csvSources)
TNSId,TNSName,discoveryName,discSurvey,raSex,decSex,raDeg,decDeg,transRedshift,specType,discMag,discMagFilter,discDate,objectUrl,hostName,hostRedshift,separationArcsec,separationNorthArcsec,separationEastArcsec
2016asf,SN2016asf,ASASSN-16cs,ASAS-SN,06:50:36.73,+31:06:45.36,102.6530,31.1126,0.021,SN Ia,17.1,V-Johnson,2016-03-06 08:09:36,https://www.wis-tns.org/object/2016asf,KUG 0647+311,,0.66,0.65,-0.13

You can save the results to file by passing in a directory path within which to save the files to. The four flavours of data (sources, photometry, spectra and files) are saved to separate files but all data can be assoicated with its transient source using the transient’s unique TNSId.

tns.csv("~/tns")
https://i.imgur.com/BwwqMBg.png
:width: 800px
:alt: csv output
json(dirPath=None)[source]

Render the results in json format

Key Arguments

  • dirPath – the path to the directory to save the rendered results to. Default None

Return

  • jsonSources – the top-level transient data

  • jsonPhot – all photometry associated with the transients

  • jsonSpec – all spectral data associated with the transients

  • jsonFiles – all files associated with the matched transients found on the tns

Usage

To render the results in json format:

jsonSources, jsonPhot, jsonSpec, jsonFiles  = tns.json()
print(jsonSources)
[
    {
        "TNSId": "2016asf",
        "TNSName": "SN2016asf",
        "decDeg": 31.1126,
        "decSex": "+31:06:45.36",
        "discDate": "2016-03-06 08:09:36",
        "discMag": "17.1",
        "discMagFilter": "V-Johnson",
        "discSurvey": "ASAS-SN",
        "discoveryName": "ASASSN-16cs",
        "hostName": "KUG 0647+311",
        "hostRedshift": null,
        "objectUrl": "https://www.wis-tns.org/object/2016asf",
        "raDeg": 102.65304166666667,
        "raSex": "06:50:36.73",
        "separationArcsec": "0.66",
        "separationEastArcsec": "-0.13",
        "separationNorthArcsec": "0.65",
        "specType": "SN Ia",
        "transRedshift": "0.021"
    }
]

You can save the results to file by passing in a directory path within which to save the files to. The four flavours of data (sources, photometry, spectra and files) are saved to separate files but all data can be assoicated with its transient source using the transient’s unique TNSId.

tns.json("~/tns")
https://i.imgur.com/wAHqARI.png
:width: 800px
:alt: json output
yaml(dirPath=None)[source]

Render the results in yaml format

Key Arguments

  • dirPath – the path to the directory to save the rendered results to. Default None

Return

  • yamlSources – the top-level transient data

  • yamlPhot – all photometry associated with the transients

  • yamlSpec – all spectral data associated with the transients

  • yamlFiles – all files associated with the matched transients found on the tns

Usage

To render the results in yaml format:

yamlSources, yamlPhot, yamlSpec, yamlFiles  = tns.yaml()
print(yamlSources)
- TNSId: 2016asf
  TNSName: SN2016asf
  decDeg: 31.1126
  decSex: '+31:06:45.36'
  discDate: '2016-03-06 08:09:36'
  discMag: '17.1'
  discMagFilter: V-Johnson
  discSurvey: ASAS-SN
  discoveryName: ASASSN-16cs
  hostName: KUG 0647+311
  hostRedshift: null
  objectUrl: https://www.wis-tns.org/object/2016asf
  raDeg: 102.65304166666667
  raSex: '06:50:36.73'
  separationArcsec: '0.66'
  separationEastArcsec: '-0.13'
  separationNorthArcsec: '0.65'
  specType: SN Ia
  transRedshift: '0.021'

You can save the results to file by passing in a directory path within which to save the files to. The four flavours of data (sources, photometry, spectra and files) are saved to separate files but all data can be assoicated with its transient source using the transient’s unique TNSId.

tns.yaml("~/tns")
https://i.imgur.com/ZpJIC6p.png
:width: 800px
:alt: yaml output
markdown(dirPath=None)[source]

Render the results in markdown format

Key Arguments

  • dirPath – the path to the directory to save the rendered results to. Default None

Return

  • markdownSources – the top-level transient data

  • markdownPhot – all photometry associated with the transients

  • markdownSpec – all spectral data associated with the transients

  • markdownFiles – all files associated with the matched transients found on the tns

Usage

To render the results in markdown table format:

markdownSources, markdownPhot, markdownSpec, markdownFiles  = tns.markdown()
print(markdownSources)
| TNSId    | TNSName    | discoveryName  | discSurvey  | raSex        | decSex        | raDeg     | decDeg   | transRedshift  | specType  | discMag  | discMagFilter  | discDate             | objectUrl                                     | hostName      | hostRedshift  | separationArcsec  | separationNorthArcsec  | separationEastArcsec  |
|:---------|:-----------|:---------------|:------------|:-------------|:--------------|:----------|:---------|:---------------|:----------|:---------|:---------------|:---------------------|:----------------------------------------------|:--------------|:--------------|:------------------|:-----------------------|:----------------------|
| 2016asf  | SN2016asf  | ASASSN-16cs    | ASAS-SN     | 06:50:36.73  | +31:06:45.36  | 102.6530  | 31.1126  | 0.021          | SN Ia     | 17.1     | V-Johnson      | 2016-03-06 08:09:36  | https://www.wis-tns.org/object/2016asf  | KUG 0647+311  |               | 0.66              | 0.65                   | -0.13                 |

You can save the results to file by passing in a directory path within which to save the files to. The four flavours of data (sources, photometry, spectra and files) are saved to separate files but all data can be assoicated with its transient source using the transient’s unique TNSId.

tns.markdown("~/tns")
https://i.imgur.com/AYLBQoJ.png
:width: 800px
:alt: markdown output
table(dirPath=None)[source]

Render the results as an ascii table

Key Arguments

  • dirPath – the path to the directory to save the rendered results to. Default None

Return

  • tableSources – the top-level transient data

  • tablePhot – all photometry associated with the transients

  • tableSpec – all spectral data associated with the transients

  • tableFiles – all files associated with the matched transients found on the tns

Usage

To render the results in ascii table format:

tableSources, tablePhot, tableSpec, tableFiles  = tns.table()
print(tableSources)
+----------+------------+----------------+-------------+--------------+---------------+-----------+----------+----------------+-----------+----------+----------------+----------------------+-----------------------------------------------+---------------+---------------+-------------------+------------------------+-----------------------+
| TNSId    | TNSName    | discoveryName  | discSurvey  | raSex        | decSex        | raDeg     | decDeg   | transRedshift  | specType  | discMag  | discMagFilter  | discDate             | objectUrl                                     | hostName      | hostRedshift  | separationArcsec  | separationNorthArcsec  | separationEastArcsec  |
+----------+------------+----------------+-------------+--------------+---------------+-----------+----------+----------------+-----------+----------+----------------+----------------------+-----------------------------------------------+---------------+---------------+-------------------+------------------------+-----------------------+
| 2016asf  | SN2016asf  | ASASSN-16cs    | ASAS-SN     | 06:50:36.73  | +31:06:45.36  | 102.6530  | 31.1126  | 0.021          | SN Ia     | 17.1     | V-Johnson      | 2016-03-06 08:09:36  | https://www.wis-tns.org/object/2016asf  | KUG 0647+311  |               | 0.66              | 0.65                   | -0.13                 |
+----------+------------+----------------+-------------+--------------+---------------+-----------+----------+----------------+-----------+----------+----------------+----------------------+-----------------------------------------------+---------------+---------------+-------------------+------------------------+-----------------------+

You can save the results to file by passing in a directory path within which to save the files to. The four flavours of data (sources, photometry, spectra and files) are saved to separate files but all data can be assoicated with its transient source using the transient’s unique TNSId.

tns.table("~/tns")
https://i.imgur.com/m09M0ho.png
:width: 800px
:alt: ascii files
mysql(tableNamePrefix='TNS', dirPath=None)[source]

Render the results as MySQL Insert statements

Key Arguments

  • tableNamePrefix – the prefix for the database table names to assign the insert statements to. Default TNS.

  • dirPath – the path to the directory to save the rendered results to. Default None

Return

  • mysqlSources – the top-level transient data

  • mysqlPhot – all photometry associated with the transients

  • mysqlSpec – all spectral data associated with the transients

  • mysqlFiles – all files associated with the matched transients found on the tns

Usage

To render the results in mysql insert format:

mysqlSources, mysqlPhot, mysqlSpec, mysqlFiles  = tns.mysql("TNS")
print(mysqlSources)
INSERT INTO `TNS_sources` (TNSId,TNSName,dateCreated,decDeg,decSex,discDate,discMag,discMagFilter,discSurvey,discoveryName,hostName,hostRedshift,objectUrl,raDeg,raSex,separationArcsec,separationEastArcsec,separationNorthArcsec,specType,transRedshift) VALUES ("2016asf" ,"SN2016asf" ,"2016-09-20T11:22:13" ,"31.1126" ,"+31:06:45.36" ,"2016-03-06 08:09:36" ,"17.1" ,"V-Johnson" ,"ASAS-SN" ,"ASASSN-16cs" ,"KUG 0647+311" ,null ,"https://www.wis-tns.org/object/2016asf" ,"102.653041667" ,"06:50:36.73" ,"0.66" ,"-0.13" ,"0.65" ,"SN Ia" ,"0.021")  ON DUPLICATE KEY UPDATE  TNSId="2016asf", TNSName="SN2016asf", dateCreated="2016-09-20T11:22:13", decDeg="31.1126", decSex="+31:06:45.36", discDate="2016-03-06 08:09:36", discMag="17.1", discMagFilter="V-Johnson", discSurvey="ASAS-SN", discoveryName="ASASSN-16cs", hostName="KUG 0647+311", hostRedshift=null, objectUrl="https://www.wis-tns.org/object/2016asf", raDeg="102.653041667", raSex="06:50:36.73", separationArcsec="0.66", separationEastArcsec="-0.13", separationNorthArcsec="0.65", specType="SN Ia", transRedshift="0.021", updated=1, dateLastModified=NOW() ;

You can save the results to file by passing in a directory path within which to save the files to. The four flavours of data (sources, photometry, spectra and files) are saved to separate files but all data can be assoicated with its transient source using the transient’s unique TNSId.

tns.mysql("TNS", "~/tns")
https://i.imgur.com/CozySPW.png
:width: 800px
:alt: mysql output
_query_tns()[source]

determine how to query the TNS, send query and parse the results

Return

  • results – a list of dictionaries (one dictionary for each result set returned from the TNS)

_get_tns_search_results()[source]

query the tns and result the response

_file_prefix()[source]

Generate a file prefix based on the type of search for saving files to disk

Return

  • prefix – the file prefix

_parse_transient_rows(content, count=False)[source]
  • parse transient rows from the TNS result page content*

Key Arguments

  • content – the content from the TNS results page.

  • count – return only the number of rows

Return

  • transientRows

_parse_discovery_information(content)[source]
  • parse discovery information from one row on the TNS results page*

Key Arguments

  • content – a table row from the TNS results page.

Return

  • discoveryData – dictionary of results

  • TNSId – the unique TNS id for the transient

_parse_photometry_data(content, TNSId)[source]

parse photometry data from a row in the tns results content

Key Arguments

  • content – a table row from the TNS results page

  • TNSId – the tns id of the transient

Return

  • photData – a list of dictionaries of the photometry data

  • relatedFilesTable – a list of dictionaries of transient photometry related files

parse the contents for related files URLs and comments

Key Arguments

  • content – the content to parse.

Return

  • relatedFiles – a list of dictionaries of transient related files

_parse_spectral_data(content, TNSId)[source]

parse spectra data from a row in the tns results content

Key Arguments

  • content – a table row from the TNS results page

  • TNSId – the tns id of the transient

Return

  • specData – a list of dictionaries of the spectral data

  • relatedFilesTable – a list of dictionaries of transient spectrum related files