Code Monkey home page Code Monkey logo

frbcat's People

Contributors

davidgardenier avatar fjankowsk avatar inespm avatar loostrum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

frbcat's Issues

TNS: 'host_redshift' not found in columns

@loostrum - Any idea why that is?

Traceback (most recent call last):
  File "/home/runner/work/FRBSTATS/FRBSTATS/FRBSTATS/tns_compare.py", line 56, in <module>
    tns = TNS(path='/home/runner/', tns_name='my_user_name', tns_id='my_user_id')
  File "/usr/local/lib/python3.10/dist-packages/frbcat/tns.py", line 54, in __init__
    self.get_data()
  File "/usr/local/lib/python3.10/dist-packages/frbcat/tns.py", line 127, in get_data
    self.clean_df(df)
  File "/usr/local/lib/python3.10/dist-packages/frbcat/tns.py", line 308, in clean_df
    df = df.astype({'tns_id': int,
  File "/usr/local/lib/python3.10/dist-packages/pandas/core/generic.py", line 6212, in astype
    raise KeyError(
KeyError: "Only a column name can be used for the key in a dtype mappings argument. 'host_redshift' not found in columns."

Not sure if something suddenly changed in the TNS (has been working fine so far).

Thanks!

New release

A new release to pypi would be useful as the current release doesn't work anymore for the TNS.
I'd add a file to the repo so it publishes to pypi automatically when you create a Github release.
I'm happy to do it if you agree.

Astropy table support

It could potentially be valuable to add astropy table support to the pandas dataframe, allowing for the use of units (currently defined manually in self.units).

Querying the TNS: cannot convert float NaN to integer

@davidgardenier - Any ideas what might be causing this error all of a sudden? Perhaps some new TNS entry contains data in an unusual format?

Traceback (most recent call last):
  File "/home/runner/work/FRBSTATS/FRBSTATS/FRBSTATS/tns_compare.py", line 56, in <module>
    tns = TNS(path='/home/runner/', tns_name='my_user_name', tns_id='my_user_id')
  File "/usr/local/lib/python3.10/dist-packages/frbcat/tns.py", line 54, in __init__
    self.get_data()
  File "/usr/local/lib/python3.10/dist-packages/frbcat/tns.py", line 127, in get_data
    self.clean_df(df)
  File "/usr/local/lib/python3.10/dist-packages/frbcat/tns.py", line 305, in clean_df
    df = df.astype({'tns_id': int,
  File "/usr/local/lib/python3.10/dist-packages/pandas/core/generic.py", line 6226, in astype
    res_col = col.astype(dtype=cdt, copy=copy, errors=errors)
  File "/usr/local/lib/python3.10/dist-packages/pandas/core/generic.py", line 6240, in astype
    new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors)
  File "/usr/local/lib/python3.10/dist-packages/pandas/core/internals/managers.py", line 450, in astype
    return self.apply("astype", dtype=dtype, copy=copy, errors=errors)
  File "/usr/local/lib/python3.10/dist-packages/pandas/core/internals/managers.py", line 352, in apply
    applied = getattr(b, f)(**kwargs)
  File "/usr/local/lib/python3.10/dist-packages/pandas/core/internals/blocks.py", line 526, in astype
    new_values = astype_array_safe(values, dtype, copy=copy, errors=errors)
  File "/usr/local/lib/python3.10/dist-packages/pandas/core/dtypes/astype.py", line 299, in astype_array_safe
    new_values = astype_array(values, dtype, copy=copy)
  File "/usr/local/lib/python3.10/dist-packages/pandas/core/dtypes/astype.py", line 230, in astype_array
    values = astype_nansafe(values, dtype, copy=copy)
  File "/usr/local/lib/python3.10/dist-packages/pandas/core/dtypes/astype.py", line 170, in astype_nansafe
    return arr.astype(dtype, copy=True)
ValueError: cannot convert float NaN to integer

Full code: https://github.com/HeRTA/FRBSTATS/blob/main/tns_compare.py

'max' raises ValueError when glob returns empty sequence

from frbcat import TNS                                                                                                                                                                                                 
tns = TNS()

Output:
                                                                                                                                                                                                                                                          
tns.py        | Attempting to retrieve FRBs from the Transient Name Server
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-e524d30646c1> in <module>
----> 1 tns = TNS()

~/miniconda3/lib/python3.7/site-packages/frbcat/tns.py in __init__(self, oneoffs, repeaters, repeat_bursts, update, path, save, mute)
     46         self.mute = mute
     47 
---> 48         self.get_data()
     49         self.filter(one_offs=self.oneoffs,
     50                     repeaters=self.repeaters,

~/miniconda3/lib/python3.7/site-packages/frbcat/tns.py in get_data(self)
    132         if self.update is False:
    133             # Find latest version of frbcat
--> 134             f = max(glob.glob(self.path + '/tns*.csv'), key=os.path.getctime)
    135             if not self.mute:
    136                 misc.pprint("Using " + f.split('/')[-1])

ValueError: max() arg is an empty sequence

Update script upon TNS migration

The migration of the TNS to the AWS will take place on Sunday, Dec 27th at 08:00 UT (and NOT on Dec 6th as was previously mentioned).

As mentioned, the new URL of the TNS will be: https://www.wis-tns.org; and the sandbox: https://sandbox.wis-tns.org

A redirect to the new URLs will be in place right after the migration, but we encourage that you verify that your scripts respond well to following 301-Redirects (whether using curl, python's requests etc...); and ultimately update the new URLs.

Support for multiple entries from TNS

For future reference: at the moment frbcat takes the latest photometry and report entry for usage in the pandas dataframe. Support could be added at a future stage to allow for multiple entries.

Data retrieval from the FRBSTATS Catalogue

The FRBSTATS Catalogue is the most accurate and complete catalogue of fast radio bursts published to date, and it is continuously maintained. It would be nice to see the frbcat package support the quick retrieval of data from the FRBSTATS Catalogue as well.

The database can be downloaded as a CSV or JSON-formatted file (whichever is more convenient to handle).

TNS: 'DataFrame' object has no attribute 'burst_bandwidth'

When running the following command (where user and id are my personal TNS login details):
tns = TNS(tns_name="user", tns_id="id", repeaters=False)
I get the following Attribute error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-e98b701f8d56> in <module>
----> 1 tns = TNS(tns_name="MyName", tns_id="MyID", repeaters=False)

/opt/anaconda3/lib/python3.9/site-packages/frbcat/tns.py in __init__(self, oneoffs, repeaters, repeat_bursts, update, path, save, mute, tns_id, tns_name)
     52         self.tns_name = tns_name
     53 
---> 54         self.get_data()
     55         self.filter(one_offs=self.oneoffs,
     56                     repeaters=self.repeaters,

/opt/anaconda3/lib/python3.9/site-packages/frbcat/tns.py in get_data(self)
    125                 entries = self.get_json()
    126                 df = self.json2df(entries)
--> 127                 self.clean_df(df)
    128 
    129                 if self.save:

/opt/anaconda3/lib/python3.9/site-packages/frbcat/tns.py in clean_df(self, df)
    365             df[c + '_err'] = err.astype(float)
    366 
--> 367         cols = df.burst_bandwidth.str.strip(' MHz').str.partition(' (')[[0, 2]]
    368         df['burst_bandwidth'] = cols[0].astype(float)
    369         err = cols[2].str.strip(')')

/opt/anaconda3/lib/python3.9/site-packages/pandas/core/generic.py in __getattr__(self, name)
   5573         ):
   5574             return self[name]
-> 5575         return object.__getattribute__(self, name)
   5576 
   5577     def __setattr__(self, name: str, value) -> None:

AttributeError: 'DataFrame' object has no attribute 'burst_bandwidth'

Could it be that I have an uncompatible pandas version? I currently have version 1.4.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.