diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..20efd1b --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..544c90b --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Tutorials +Author tools for AAS Journals. + +``figureset:`` Python script to write out the AASTeX 6 Figure Set markup for online (HTML) figures. diff --git a/figureset/README.md b/figureset/README.md new file mode 100644 index 0000000..139597f --- /dev/null +++ b/figureset/README.md @@ -0,0 +1,2 @@ + + diff --git a/figureset/figure1set.tex b/figureset/figure1set.tex new file mode 100644 index 0000000..f0cb6ee --- /dev/null +++ b/figureset/figure1set.tex @@ -0,0 +1,57 @@ +\figsetstart +\figsetnum{1} +\figsettitle{Young Stellar Object Scrapbook} + +\figsetgrpstart +\figsetgrpnum{1.1} +\figsetgrptitle{LkHa823} +\figsetplot{protostar1.pdf} +\figsetgrpnote{LkHa823 is a Class III object and displays forbidden lines, Halpha in emission.} +\figsetgrpend + +\figsetgrpstart +\figsetgrpnum{1.2} +\figsetgrptitle{Ori32-5} +\figsetplot{protostar2a.pdf} +\figsetplot{protostar2b.pdf} +\figsetgrpnote{Ori32-5 is a Class II object and is completely featureless.} +\figsetgrpend + +\figsetgrpstart +\figsetgrpnum{1.3} +\figsetgrptitle{1} +\figsetplot{fig1.ps} +\figsetgrpnote{} +\figsetgrpend + +\figsetgrpstart +\figsetgrpnum{1.4} +\figsetgrptitle{2} +\figsetplot{fig2.ps} +\figsetgrpnote{} +\figsetgrpend + +\figsetgrpstart +\figsetgrpnum{1.5} +\figsetgrptitle{3} +\figsetplot{fig3.ps} +\figsetgrpnote{} +\figsetgrpend + +\figsetgrpstart +\figsetgrpnum{1.6} +\figsetgrptitle{4} +\figsetplot{fig4.ps} +\figsetgrpnote{} +\figsetgrpend + +\figsetgrpstart +\figsetgrpnum{1.7} +\figsetgrptitle{5} +\figsetplot{fig5a.ps} +\figsetplot{fig5b.ps} +\figsetplot{fig5c.ps} +\figsetgrpnote{} +\figsetgrpend + +\figsetend diff --git a/figureset/make_translation.sh b/figureset/make_translation.sh new file mode 100755 index 0000000..0ae8f49 --- /dev/null +++ b/figureset/make_translation.sh @@ -0,0 +1,2 @@ +# example script to turn datatable into translation table +grep JW datafile1.txt | awk '{print$1".pdf,"$1","$7"\n"$1"rgb.pdf,"$1","$7}' >| translation.csv diff --git a/figureset/newfigureset.py b/figureset/newfigureset.py new file mode 100644 index 0000000..d6a2010 --- /dev/null +++ b/figureset/newfigureset.py @@ -0,0 +1,56 @@ + +# coding: utf-8 +import sys +import csv, yaml + + +# import yaml config +with open(sys.argv[1], "r") as stream: + y = yaml.load(stream) + +# open translation table +t = [] +with open(y['translationfile'], "r") as tfile: + treader = csv.reader(tfile) + for row in treader: + t.append(row) + +# pad table rows to same length with strings +lt = max([len(row) for row in t]) + +markup = [] +markup.append("\\figsetstart") +markup.append("\\figsetnum{{{0}}}".format(y['fignum'])) +markup.append("\\figsettitle{{{0}}}".format(y['settitle'])) +markup.append("") + +ft = [] +fn = 1 +for i, row in enumerate(t): + if row[1] == ft: + markup.insert(len(markup)-3, "\\figsetplot{{{0}}}".format(row[0])) + else: + if len(row) < lt: + row.extend((lt - len(row)) * [""]) + caption = "" + else: + caption = y['caption'].strip("\n") + markup.append("\\figsetgrpstart") + markup.append("\\figsetgrpnum{{{0}.{1}}}".format(y['fignum'], fn)) + markup.append("\\figsetgrptitle{{{0}}}".format(row[1])) + markup.append("\\figsetplot{{{0}}}".format(row[0])) + markup.append("\\figsetgrpnote{{{0}}}".format(caption.format(*row))) + markup.append("\\figsetgrpend") + markup.append("") + fn = fn + 1 + ft = row[1] + +markup.append("\\figsetend") + +# write out +with open('figure{0}set.tex'.format(y['fignum']), mode='w', encoding='utf-8') as ofile: + ofile.write('\n'.join(markup)) + ofile.write('\n') + + + diff --git a/figureset/translation.csv b/figureset/translation.csv new file mode 100644 index 0000000..5a0f729 --- /dev/null +++ b/figureset/translation.csv @@ -0,0 +1,10 @@ +protostar1.pdf,LkHa823,III,"displays forbidden lines, Halpha in emission." +protostar2a.pdf,Ori32-5,II,"is completely featureless." +protostar2b.pdf,Ori32-5,II +fig1.ps,1 +fig2.ps,2 +fig3.ps,3 +fig4.ps,4 +fig5a.ps,5 +fig5b.ps,5 +fig5c.ps,5 diff --git a/figureset/translation.yaml b/figureset/translation.yaml new file mode 100644 index 0000000..15aa576 --- /dev/null +++ b/figureset/translation.yaml @@ -0,0 +1,41 @@ +--- +# yaml configuration file for newfigureset.py +# +# the required elements are: +# +# fignum: The figure number of the figure set. +# setttitle: The title for the figure set +# translationfile: A comma delimited translation table (see below) +# caption: A caption string for the set. +# +# The csv translation file must contain a list of files and figure titles, +# one on each row, along with an optional list of attributes for each row: +# +# filename, figure title [, attribute1, attribute2...attributeN] +# +#, e.g., +# +# protostar1.pdf,LkHa823,III,"displays forbidden lines, Halpha in emission." +# protostar2a.pdf,Ori32-5,II,"is completely featureless." +# protostar2b.pdf,Ori32-5,II +# +# to assign multiple figure files to a single figure in the set, give them the +# same figure title, e.g., Ori32-5 above. +# +# the caption string below can be written to map attributes of each row in the +# csv file as string elements of the caption. Given the example above a caption +# string of +# +# caption: {1} is a Class {2} object and {3} +# +# would write captions of +# +# LkHa823 is a Class III object and displays forbidden lines, Halpha in emission. +# Ori32-5 is a Class II object and is completely featureless. +# +fignum: 1 +settitle: Young Stellar Object Scrapbook +translationfile: "translation.csv" +caption: > + {1} is a Class {2} object and {3} +...