From da62560e830ddd74b6f03be0484fd0b2529c6b7a Mon Sep 17 00:00:00 2001 From: William O'Mullane Date: Fri, 30 Aug 2024 16:54:08 -0400 Subject: [PATCH 1/3] add ascom author style --- bin/db2authors.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/db2authors.py b/bin/db2authors.py index 2d23dfa0..42cb8fdd 100755 --- a/bin/db2authors.py +++ b/bin/db2authors.py @@ -36,7 +36,7 @@ # this should probably be a dict with the value of affil_cmd # the keys could then be passed to the arg parser. -OUTPUT_MODES = ["aas", "spie", "adass", "arxiv"] +OUTPUT_MODES = ["aas", "spie", "adass", "arxiv", "ascom"] description = __doc__ formatter = argparse.RawDescriptionHelpFormatter @@ -87,6 +87,10 @@ buffer_authors = True author_super = True +if args.mode == "ascom": + buffer_affil = True + affil_out_sep = ", " + with open(authorfile) as fh: authors = yaml.safe_load(fh) @@ -178,7 +182,10 @@ def get_initials(initials): if args.noafil: affilAuth = affilAuth else: - affilAuth = auth_afil_form.format(affilAuth, affilSep, str(affilInd)) + if args.mode == "ascom": + affilAuth = auth_afil_form.format(str(affilInd), affilAuth, affilSep) + else: + affilAuth = auth_afil_form.format(affilAuth, affilSep, str(affilInd)) affilSep = " " @@ -191,6 +198,7 @@ def get_initials(initials): orc = auth.get("orcid", "") if orc is None: orc = "" + email = auth.get("email", "") if email is None: email = "" @@ -235,7 +243,10 @@ def get_initials(initials): indexOutput.append(rf"%\aindex{{{surname},{justInitials}}}") if buffer_authors: - authOutput.append(author_form.format(initials, surname, affilAuth)) + if args.mode == "ascom": + authOutput.append(author_form.format(affilAuth, initials, surname)) + else: + authOutput.append(author_form.format(initials, surname, affilAuth)) allAffil = allAffil + affilOutput else: print(author_form.format(orcid, initials, surname)) From 8848d0123afa5eafc2229bdf09ff79204d404eae Mon Sep 17 00:00:00 2001 From: William O'Mullane Date: Fri, 30 Aug 2024 17:41:55 -0400 Subject: [PATCH 2/3] Tim's comments --- bin/db2authors.py | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/bin/db2authors.py b/bin/db2authors.py index 42cb8fdd..827aeab2 100755 --- a/bin/db2authors.py +++ b/bin/db2authors.py @@ -56,19 +56,19 @@ buffer_affil = False # hold affiliation until after author output buffer_authors = False # out put authors in one \author command (adass) affil_cmd = "affiliation" # command for latex affiliation -affil_form = r"\{}[{}]{{{}}}" # format of the affiliation -auth_afil_form = "{}{}{}" # format of author with affiliation -author_form = r"\author{}{{{}~{}}}" # format of the author +affil_form = r"\{cmd}[{affilId}]{{{affil}}}" # format of the affiliation +auth_afil_form = "{affilAuth}{affilSep}{affilInd}" # format of author with affiliation +author_form = r"\author{orcid}{{{initials}~{surname}}}" # format of the author author_super = False # Author affiliation as super script author_sep = " and " # The default is AAS and if no mode is specified you get that if args.mode == "arxiv": - author_form = r"{} {}{}" + author_form = "{orcid} {initials}{surname}" affil_cmd = "" affil_out_sep = ", " - affil_form = r"{}({}) {}" - auth_afil_form = "{}{}({})" + affil_form = r"{cmd}({affilId}) {affil}" + auth_afil_form = "{affilAuth}{affilSep}({affilInd})" # format of author with affiliation buffer_affil = True buffer_authors = True author_sep = ", " @@ -80,16 +80,18 @@ if args.mode == "adass": affil_cmd = "affil" affil_out_sep = "\n" - affil_form = r"\{}{{$^{}${}}}" - auth_afil_form = "{}{}$^{}$" - author_form = r"{}~{}{}" # initial, surname, affil + affil_form = r"\{cmd}{{$^{affilId}${affil}}}" + auth_afil_form = "{affilAuth}{affilSep}$^{affilInd}$" + author_form = "{initials}~{surname}{affilAuth}" # initial, surname, affil buffer_affil = True buffer_authors = True author_super = True if args.mode == "ascom": + author_form = r"\author[{affilAuth}]{{{initials}~{surname}}}" # format of the author buffer_affil = True affil_out_sep = ", " + auth_afil_form = "{affilInd}{affilAuth}{affilSep}" with open(authorfile) as fh: authors = yaml.safe_load(fh) @@ -176,16 +178,13 @@ def get_initials(initials): if theAffil not in affilset: affilset.append(theAffil) # unforuneately you can not output an affil before an author - affilOutput.append(affil_form.format(affil_cmd, len(affilset), affil[theAffil])) + affilOutput.append(affil_form.format(cmd=affil_cmd, affilId=len(affilset), affil=affil[theAffil])) affilInd = affilset.index(theAffil) + 1 if args.noafil: affilAuth = affilAuth else: - if args.mode == "ascom": - affilAuth = auth_afil_form.format(str(affilInd), affilAuth, affilSep) - else: - affilAuth = auth_afil_form.format(affilAuth, affilSep, str(affilInd)) + affilAuth = auth_afil_form.format(affilAuth=affilAuth, affilInd=affilInd, affilSep=affilSep) affilSep = " " @@ -237,19 +236,16 @@ def get_initials(initials): if args.mode == "arxiv": affilOutput = [] # reset this - affilOutput.append(affil_form.format(affil_cmd, len(affilset), tute)) + affilOutput.append(affil_form.format(cmd=affil_cmd, affilId=len(affilset), affil=tute)) justInitials = get_initials(initials) indexOutput.append(rf"%\aindex{{{surname},{justInitials}}}") if buffer_authors: - if args.mode == "ascom": - authOutput.append(author_form.format(affilAuth, initials, surname)) - else: - authOutput.append(author_form.format(initials, surname, affilAuth)) + authOutput.append(author_form.format(initials=initials, surname=surname, affilAuth=affilAuth)) allAffil = allAffil + affilOutput else: - print(author_form.format(orcid, initials, surname)) + print(author_form.format(orcid=orcid, initials=initials, surname=surname, affilAuth=affilAuth)) if buffer_affil: print(*affilOutput, sep="\n") else: From 2c2f28b29575bcff72d5b51fa5bc246f6f2053b9 Mon Sep 17 00:00:00 2001 From: William O'Mullane Date: Fri, 30 Aug 2024 17:48:33 -0400 Subject: [PATCH 3/3] one more simplification --- bin/db2authors.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/db2authors.py b/bin/db2authors.py index 827aeab2..a9f127f2 100755 --- a/bin/db2authors.py +++ b/bin/db2authors.py @@ -241,11 +241,12 @@ def get_initials(initials): justInitials = get_initials(initials) indexOutput.append(rf"%\aindex{{{surname},{justInitials}}}") + author = author_form.format(orcid=orcid, initials=initials, surname=surname, affilAuth=affilAuth) if buffer_authors: - authOutput.append(author_form.format(initials=initials, surname=surname, affilAuth=affilAuth)) + authOutput.append(author) allAffil = allAffil + affilOutput else: - print(author_form.format(orcid=orcid, initials=initials, surname=surname, affilAuth=affilAuth)) + print(author) if buffer_affil: print(*affilOutput, sep="\n") else: