Giter VIP home page Giter VIP logo

sunstardb's Introduction

sunstardb - the solar-stellar database

sunstardb is a publicly accessible database of observations relevant to the study of stellar magnetism. These observations form the basis of the field known as the "solar-stellar connection," which seeks to understand the mechanisms for the production of magnetic field in stars and their dependence on fundamental properties such as mass, luminosity, etc., as well as to understand the place of the Sun's magnetism in this context. sunstardb aggregates and organizes results published in the literature into one place in order to accelerate research efforts in the solar-stellar connection.

sunstardb consists of the following components:

  • postgreSQL database
  • python APIs for interactive access
  • TODO: a web front-end for basic reporting of database contents

More information and announcements may be found at https://www2.hao.ucar.edu/sunstardb

An example can be seen in github by clicking the .ipynb files above, or from this link. (Note that the interactive tables do not work in these links, but do work when running the jupyter notebook server locally by following the installation instructions below.)

Requirements

sunstardb requires the following packages:

Installation

  1. Install the requirements listed above and ensure they are in your python environment.

  2. Download the latest release of sunstardb

  3. In a terminal, change directory to the release downloaded above.

  4. Fetch the configuration file using one of the following options:

    • Using wget:

    wget --user-agent="Lynx/0 libwww-FM/0" 'https://goo.gl/h1WH2A' -O sunstardb.cfg

    • Using curl:

    curl -L --user-agent "Lynx/0 libwww-FM/0" 'https://goo.gl/h1WH2A' > sunstardb.cfg

    • Or, if neither of the above utilities are installed, using your usual web browser. Go to http://bit.ly/sunstardb_user and save the output to a file named sunstardb.cfg in the top-level folder.
  5. export PYTHONPATH=$PWD:$PYTHONPATH

  6. Run the example notebook:

    jupyter notebook 'sunstardb long example.ipynb'

    In the jupyter notebook menu, select "Cell -> Run All"

sunstardb's People

Contributors

rickyegeland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sunstardb's Issues

Bug: Incorrect handling of NULL in results returning astropy Table

For example:

result = db.fetch_data_table('Baliunas1995', ['S_mean', 'activity_class', 'Pcyc', 'Pcyc2'], meta={'Pcyc':'FAPGrade'}, nulls=True

has a dtype:

[('star', 'S12'), ('S_mean', '<f8'), ('activity_class', 'S12'), ('Pcyc', 'O'), ('Pcyc2', 'O'), ('FAPGrade', 'O')]

Which causes all sorts of problems when trying to plot, for example. The ugly workaround is to cast the column post-fetch:

   print result.dtype
   for i, col in enumerate(result.colnames):
        if col in ('Pcyc', 'Pcyc2'):
            dtype[i] = 'float64'
            result[col].fill_value = np.nan
            result[col] = result[col].astype('float64')
        if col in ('FAPGrade'):
            dtype[i] = 'S'
            result[col].mask = [x is None for x in result[col]]
    result = astropy.table.Table(result, dtype=dtype)
    for col in ('Pcyc', 'Pcyc2'):
        result[col].mask = np.isnan(result[col])
    print "Final:", result.dtype

This needs to be handled in fetchall_astropy()

All APIs returning star identifiers should return user-preferred alias

Currently APIs returning stars return the canonical star name, which is set by SIMBAD. Users must build a list of names of their preferred alias (e.g. HD number). For example:

    # Fetch Cycle Data from sunstardb
    result = db.fetch_data_table('Baliunas1995', ['S_mean', 'activity_class', 'Pcyc', 'Pcyc2'], meta={'Pcyc':'FAPGrade'}, nulls=True)

    # Add an HD number column
    hds = []
    hdnums = []
    for star in result['star']:
        if star == 'Sun':
            hd = 'Sun'
            num = 0
        else:
            hd = db.fetch_star_alias(name=star, type='HD')
            num = int(re.match('^HD (\d+)', hd).group(1))
        hds.append(hd)
        hdnums.append(num)
    result['HD'] = hds
    result['Sort'] = hdnums

(Here the 'Sort' column allows the astropy.table.Table to sort the HD numbers in numerical, not lexical, order.)

Instead the user should be able to specify a list of preferred alias types. API example:

    # Fetch Cycle Data from sunstardb
    result = db.fetch_data_table('Baliunas1995', ['S_mean', 'activity_class', 'Pcyc', 'Pcyc2'], meta={'Pcyc':'FAPGrade'}, nulls=True, star_alias=['HD', 'GJ'])

If aliases are not available, the default can be the canonical identifier (star.name in the DB)

Issue connecting to database

I'm getting an error with the command db = sunstardb.database.SunStarDB() which returns OperationalError: could not translate host name "sunstardb.hao.ucar.edu" to address: nodename nor servname provided, or not known.

Trying a ping to sunstardb.hao.ucar.edu looks like the server doesn't exist anymore, is there an up-to-date address to use? Thanks!

fetchall_stars() function

An API should be provided to fetch all stars for which a measurement of a particular datatype exists. API example:

Prot_stars = db.fetchall_stars(with_datatype='Prot')

Other useful options could be from_origin, from_source, from_dataset, from_instrument.

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.