Creating a Database with astrodbkit

The astrodbkit package can be used to modify an existing SQL database (such as The BDNYC Database) but it can also be used to create and populate a SQL database from scratch.

To do this, import the BDdb module and create a new database with
from astrodbkit import astrodb
dbpath = '/path/to/new_database.db'
astrodb.create_databse(dbpath)

Then load your new database with

db = astrodb.get_database(dbpath)

and start adding tables! The db.table() method accepts as its arguments the table name, list of field names, and list of data types like so:

db.table('my_new_table', ['field1','field2'], ['INTEGER','TEXT'], new_table=True)

Note new_table=True is necessary to create a new table. Otherwise, it looks for an existing table to modify (which you could do as well!).

To populate your new database with data, read the documentation here or a summary at Adding Data to the BDNYC Database.

As always, I recommend the SQLite Browser for a nice GUI to make changes outside of the command line.

Happy databasing!

BDNYC at CUWiP 2016

The Conference for Undergraduate Women in Physics, or CUWiP, is a set of simultaneous conferences taking place across the United States and supported by the American Physical Society. A variety of activities take place in the conferences including plenary talks, panel discussions, student posters and talks, workshops, and graduate school and career fairs.

This year, BDNYC members Victoria DiTomasso, Haley Fica, and Ellie Schwab attended CUWiP. Victoria and Ellie attended the conference held at Wesleyan University, while Haley attended the one held at Georgia Institute of Technology. All three presented posters on the research they carry out with BDNYC. You can find copies of the posters below.

Continue reading

Updating the astrodbkit documentation

As you make changes to the astrodbkit repository on Github, you may find that the documentation needs updating. Luckily, we use the invaluable Sphinx and the awesome ReadTheDocs to generate the documentation so this is fairly simple.

First, make sure you update the appropriate doc strings (those informative green bits just below the function definition) as this is what Sphinx will use to generate the documentation!

Start in the top level astrodbkit directory and generate the documentation from the module docstrings with

sphinx-build docs astrodbkit -a

Then cd into the docs directory and rebuild the html files with

cd docs
make html

Now move back to the top level directory and add, commit, and push your changes to Github with something like

cd ..
git add /docs
git commit -m "Updated the documentation for methods x, y, and z."
git push origin <your_branch>

All set! Refresh the page (after a few minutes so ReadTheDocs can build the pages) and make sure everything is to your liking. Well done.

And just in case, here's a great tutorial for getting started with Sphinx and here's the official documentation.

A New Focus for the BDNYC Blog

With this coming year, we are aiming to refocus the content in this blog. While this blog does include general purpose information about brown dwarf research, most of the content was geared towards internal descriptions of our software, our database, and our setup that are relevant only for members of BDNYC. We're now using Trac to manage the internal workings of our team and will be changing some of the content you see on these pages.

From now on, you'll see posts describing general tips and tricks, including coding, project management techniques (such as using Trac), and observing tricks. You'll also see posts announcing team publications as well as team presence at conferences such as AAS. Finally, we hope to publish posts describing the small, incremental steps we take as we carry out our research, which include interesting results and plots.

We hope these changes will result in more frequent posts and will make the blog more valuable to the community as a whole.

BDNYC at Las Campanas Observatory

BDNYC team at Las Campanas Observatory. From left to right: Sara Camnasio, Munazza Alam, Haley Fica, Jackie Faherty

This past September, four members of the BDNYC team travelled to Chile to observe at Las Campanas Observatories (LCO). This team was led by Jackie Faherty and included undergraduate students Munazza Alam, Sara Camnasio, and Haley Fica. Both Munazza and Sara were funded by National Geographic Young Explorers Grants.

Las Campanas Observatories is one of the major telescope facilities in Chile, home to the two Magellan 6.5-meter telescopes and the soon-to-be-constructed Giant Magellan Telescope. For this observing run, the team had a single night on the du Pont 3-meter telescope and two nights on the Baade Magellan telescope. The aim of the run was observing cold brown dwarfs to obtain parallaxes with CAPSCam on the du Pont and FourStar on Baade as well as spectra with FIRE on Baade.

While the weather did not cooperate throughout the run, with a mix of high humidity, high winds, and clouds, that did not deter the team from pushing forward and getting as much data as they could. The all-ladies team has contributed to posts in the Las Campanas Belles blog, which details the adventures of women scientists at Las Campanas and other observatories. The below links direct to each student’s perspective and two summary posts.

Jackie Faherty summary posts:
It's a Ladies Extravaganza at Las Campanas
Thems The Breaks....

Munazza Alam: Maravilla

Sara Camnasio: Setting Foot in Chile (and trying to keep it still)

Haley Fica: A first time Observer

Deploying Package Releases to PyPI

So you've made some cool new improvements to your Python package and you want to deploy a new release. It's just a few easy steps.

  1. After your package modules have been updated, you have to update the version number in your setup.py file. The format is major.minor.micro depending on what you changed. For example, a small bug fix to v0.2.3 would increment to v0.2.4 while a new feature might increment to v0.3.0.
  2. Then make sure all the changes are committed and pushed to Github.
  3. Build with python setup.py sdist
  4. Twine with twine upload dist/compressed_package_filename

That's it!

Adding Data to a SQL Database using astrodbkit

To add data to any table, there are two easy steps. As our working example, we'll add some new objects to the SOURCES table.

Step 1: Create an ascii file of the data

First, you must choose a delimiter, which is just the character that will break up the data into columns. I recommend a pipe '|' character since they don't normally appear in text. This is better than a comma since some data fields may have comma-separated values.

Put the data to be added in an ascii file with the following formatting:

  1. The first line must be the |-separated column names to insert/update, e.g. ra|dec|publication_id. Note that the column names in the ascii file need not be in the same order as the table. Also, only the column names that match will be added and non-matching or missing column names will be ignored, e.g. spectral_type|ra|publication_id|dec will ignore the spectral_type values as this is not a column in the SOURCES table and input the other columns in the correct places.
  2. If a record (i.e. a line in your ascii file) has no value for a particular column, type nothing. E.g. for the given column names ra|dec|publication_id|comments, a record with no publication_id should read 34.567|12.834||This object is my favorite!.

Step 2: Add the data to the specified table

To add the data to the table (in our example, the SOURCES table), import astrodbkit and initialize the .db file. Then run the add_data() method with the path to the ascii file as the first argument and the table to add the data to as the second argument. Be sure to specify your delimiter with delim='|'. Here's what that looks like:

from astrodbkit import astrodb
db = astrodb.get_db('/path/to/the/database/file.db')
db.add_data('/path/to/the/upload/file.csv', 'sources', delim='|')

That's it!

BDNYC at AAS 225

BDNYC (and friends) are out in force for the 225th meeting of the American Astronomical Society!

Please come see our posters and talks (mostly on Monday). To whet your appetite, or if you missed them, here are some samplers:

Munazza Alam (Monday, 138.40)
High-Resolution Spectral Analysis of Red & Blue L Dwarfs
AAS225_Munazza_posterSara Camnasio (Monday, 138.39)
Multi-resolution Analysis of Red and Blue L Dwarfs
AAS225_Sara_posterKelle Cruz and Stephanie Douglas (Monday, 138.37)
When good fits go wrong: Untangling Physical Parameters of Warm Brown Dwarfs

AAS225_Stephanie_posterStephanie Douglas (Monday 138.19)
Rotation and Activity in Praesepe and the Hyades

AAS225_Steph_poster2Jackie Faherty (Talk, Monday 130.05)
Clouds in the Coldest Brown Dwarfs

Joe Filippazzo (Monday, 138.34)
Fundamental Parameters for an Age Calibrated Sequence of the Lowest Mass Stars to the Highest Mass Planets
Joe Filippazzo - AAS225

Paige Giorla (Monday, 138.44)
T Dwarf Model Fits for Spectral Standards at Low Spectral Resolution
AAS225_Paige_posterKay Hiranaka (Talk, Monday 130.04D)
Constraining the Properties of the Dust Haze in the Atmospheres of Young Brown Dwarfs

Erini Lambrides (Thursday, 432.02)
Can 3000 IR spectra unveil the connection between AGN and the interstellar medium of their host galaxies?

Emily Rice (Tuesday, 243.02)
STARtorialist: Astronomy Outreach via Fashion, Sci-Fi, & Pop Culture
AAS225_STARtorialistAdric Riedel (Monday, 138.38)
The Young and the Red: What we can learn from Young Brown Dwarfs
AAS225_Adric_poster

Using WriteLaTeX for Collaborative Papers

Update: WriteLaTeX is now Overleaf

We all love Google Docs. It's a functional and convenient way to share and collaboratively edit documents across platforms, time zones, and even continents. We in the BDNYC group use it extensively.

But what if you want to write a scientific paper? Google Docs, as awesome as it is, is not much more than a word processor. We want the internal hyperlinks for sections, figures, tables, and citations, elegant mathematical formulae, well-formatted tables, more control over where and how our components are arranged - in a word, LaTeX. Yes, LaTeX has its own host of problems, but it's very good at what it does.

There are a number of collaborative editing projects out there - Authorea springs to mind. But one of the simpler options out there is actually pretty good: WriteLaTeX.
Continue reading