def is_before(y, by, m=12, d=None, bm=12, bd=None): """ tests whether a date is on or before another date Parameters ---------- y : int the year to be tested by : int the before year m : int or str the month to be tested. Optional, defaults to Dec d : int the day to be tested. Defaults to last day of the month bm : int or str the before month. Optional, defaults to Dec bd: int the before day. Optional, defaults to last day of the month Returns ------- True if the target date is the same as, or earlier than, the before date """ if not d: d = monthrange(y, month_to_int(m))[1] if not bd: bd = monthrange(by, month_to_int(bm))[1] b = "{}/{}/{}".format(bd, month_to_int(bm), by) d = "{}/{}/{}".format(d, month_to_int(m), y) before = time.mktime(datetime.strptime(b, "%d/%m/%Y").timetuple()) date = time.mktime(datetime.strptime(d, "%d/%m/%Y").timetuple()) return before >= date
def latex(self): """Render latex template""" for group in self.gtx["groups"]: pi = fuzzy_retrieval(self.gtx["people"], ["aka", "name"], group["pi_name"]) grants = list(self.gtx["grants"]) current_grants = [ g for g in grants if is_current( *[ g.get(s, 1) for s in [ "begin_year", "end_year", "begin_month", "begin_day", "end_month", "end_day", ] ] ) ] pending_grants = [ g for g in grants if is_pending( *[g[s] for s in ["begin_year", "begin_month", "begin_day"]] ) ] current_grants, _, _ = filter_grants( current_grants, {pi["name"]}, pi=False, multi_pi=True ) pending_grants, _, _ = filter_grants( pending_grants, {pi["name"]}, pi=False, multi_pi=True ) grants = pending_grants + current_grants for grant in grants: grant.update( award_start_date="{2}-{1}-{0}".format( grant["begin_day"], month_to_int(grant["begin_month"]), grant["begin_year"], ), award_end_date="{2}-{1}-{0}".format( grant["end_day"], month_to_int(grant["end_month"]), grant["end_year"], ), ) self.render( "current_pending.tex", "cpp.tex", pi=pi, pending=pending_grants, current=current_grants, pi_upper=pi["name"].upper(), group=group, ) self.pdf("cpp")
def is_since(y, sy, m=1, d=1, sm=1, sd=1): """ tests whether a date is on or since another date Parameters ---------- y : int the year to be tested sy : int the since year m : int or str the month to be tested. Optional, defaults to Jan d : int the day to be tested. Defaults to 1 sm : int or str the since month. Optional, defaults to Jan sd: int the since day. Optional, defaults to 1 Returns ------- True if the target date is the same as, or more recent than, the since date """ s = "{}/{}/{}".format(sd, month_to_int(sm), sy) d = "{}/{}/{}".format(d, month_to_int(m), y) since = time.mktime(datetime.strptime(s, "%d/%m/%Y").timetuple()) date = time.mktime(datetime.strptime(d, "%d/%m/%Y").timetuple()) return since <= date
def has_finished(ey, em=None, ed=None): """ true if today is before the dates given, inclusive Parameters ---------- ey : int end year, the year to check today against em : int or str. end month, the month to check today against. Should be integer or in regolith MONTHS. default is 1 ed : int. end-day, the day to check today against. Default is last day of the month Returns ------- bool true if today is before dates given """ if not em: em = 12 if not ed: ed = monthrange(ey, month_to_int(em))[1] e = "{}/{}/{}".format(ed, month_to_int(em), ey) end = time.mktime(datetime.strptime(e, "%d/%m/%Y").timetuple()) return end <= time.time()
def get_coauthors_from_pubs(rc, pubs, not_person): """Get co-authors' names from the publication. Not include the person itself.""" not_person_akas = [not_person['_id'], not_person['name']] + not_person['aka'] my_collabs = list() for pub in pubs: pub_date = dt.date(int(pub.get("year")), month_to_int(pub.get("month")),1) my_collabs.extend( [ (collabs, pub_date) for collabs in (names for names in pub.get('author', [])) ] ) my_collabs.sort(key=lambda x: x[1], reverse=True) collab_buffer, my_collab_set = [], [] for collab in my_collabs: person = fuzzy_retrieval(all_docs_from_collection( rc.client, "people"), ["name", "aka", "_id"], collab[0], case_sensitive=False) if not person: person = fuzzy_retrieval(all_docs_from_collection( rc.client, "contacts"), ["name", "aka", "_id"], collab[0], case_sensitive=False) if not person: person = {'_id': collab[0]} person_id = person['_id'] if person_id not in collab_buffer and collab[0] not in not_person_akas: my_collab_set.append(collab) collab_buffer.append(person_id) return my_collab_set
def has_started(sy, sm=None, sd=None): """ true if today is after the dates given, inclusive Parameters ---------- sy : int the year to check today against sm : int or str. the month to check today against. Should be integer or in regolith MONTHS. default is 1 sd : int. the day to check today against. Default is 1 Returns ------- bool true if today is after dates given """ if not sm: sm = 1 if not sd: sd = 1 s = "{}/{}/{}".format(sd, month_to_int(sm), sy) start = time.mktime(datetime.strptime(s, "%d/%m/%Y").timetuple()) return start <= time.time()
def month_and_year(m=None, y=None): """Creates a string from month and year data, if available.""" if y is None: return "present" if m is None: return str(y) m = month_to_int(m) return '{0} {1}'.format(SHORT_MONTH_NAMES[m], y)
def latex(self): """Render latex template""" for group in self.gtx['groups']: pi = fuzzy_retrieval(self.gtx['people'], ['aka', 'name'], group['pi_name']) grants = list(self.gtx['grants']) current_grants = [ g for g in grants if is_current(*[ g.get(s, 1) for s in [ 'begin_day', 'begin_month', 'begin_year', 'end_day', 'end_month', 'end_year' ] ]) ] pending_grants = [ g for g in grants if is_pending( * [g[s] for s in ['begin_day', 'begin_month', 'begin_year']]) ] current_grants, _, _ = filter_grants(current_grants, {pi['name']}, pi=False, multi_pi=True) pending_grants, _, _ = filter_grants(pending_grants, {pi['name']}, pi=False, multi_pi=True) grants = pending_grants + current_grants for grant in grants: grant.update(award_start_date='{2}-{1}-{0}'.format( grant['begin_day'], month_to_int(grant['begin_month']), grant['begin_year']), award_end_date='{2}-{1}-{0}'.format( grant['end_day'], month_to_int(grant['end_month']), grant['end_year'])) self.render('current_pending.tex', 'cpp.tex', pi=pi, pending=pending_grants, current=current_grants, pi_upper=pi['name'].upper(), group=group) self.pdf('cpp')
def get_coauthors_from_pubs(rc, pubs, not_person): """Get co-authors' names from the publication. Not include the person itself.""" not_person_akas = [not_person['_id'], not_person['name']] + not_person['aka'] my_collabs = list() for pub in pubs: pub_date = dt.date(int(pub.get("year")), month_to_int(pub.get("month")),1) my_collabs.extend( [ {"name": collabs, "interaction_date": pub_date, "type": "co-author"} for collabs in (names for names in pub.get('author', [])) ] ) my_collabs.sort(key=lambda x: x["interaction_date"], reverse=True) coauthors = retrieve_names_and_insts(rc, my_collabs, not_person_akas) return coauthors
def is_between(y, sy, by, m=1, d=1, sm=1, sd=1, bm=12, bd=None): """ tests whether a date is on or between two other dates returns true if the target date is between the since date and the before date, inclusive. Parameters ---------- y : int the year to be tested sy : int the since year by : int the before year m : int or str the month to be tested. Optional, defaults to Jan d : int the day to be tested. Defaults to 1 sm : int or str the since month. Optional, defaults to Jan bm : int or str the before month. Optional, defaults to Dec sd: int the since day. Optional, defaults to 1 bd: int the before day. Optional, defaults to 28 Returns ------- True if the target date is between the since date and the before date, inclusive (i.e., returns true if the target date is the same as either the since date or the before date) """ if not bd: bd = monthrange(by, month_to_int(bm))[1] return is_since(y, sy, m=m, d=d, sm=sm, sd=sd) and is_before( y, by, m=m, d=d, bm=bm, bd=bd )
def latex(self): """Render latex template""" for group in self.gtx["groups"]: grp = group["_id"] pi = fuzzy_retrieval(self.gtx["people"], ["aka", "name"], group["pi_name"]) pinames = pi["name"].split() piinitialslist = [i[0] for i in pinames] pi['initials'] = "".join(piinitialslist).upper() grants = merge_collections(self.gtx["proposals"], self.gtx["grants"], "proposal_id") for g in grants: for person in g["team"]: rperson = fuzzy_retrieval(self.gtx["people"], ["aka", "name"], person["name"]) if rperson: person["name"] = rperson["name"] if g.get('budget'): amounts = [i.get('amount') for i in g.get('budget')] g['subaward_amount'] = sum(amounts) current_grants = [dict(g) for g in grants if is_current(g)] current_grants, _, _ = filter_grants(current_grants, {pi["name"]}, pi=False, multi_pi=True) for g in current_grants: if g.get('budget'): amounts = [i.get('amount') for i in g.get('budget')] g['subaward_amount'] = sum(amounts) pending_grants = [ g for g in self.gtx["proposals"] if is_pending(g["status"]) ] for g in pending_grants: for person in g["team"]: rperson = fuzzy_retrieval(self.gtx["people"], ["aka", "name"], person["name"]) if rperson: person["name"] = rperson["name"] pending_grants, _, _ = filter_grants(pending_grants, {pi["name"]}, pi=False, multi_pi=True) grants = pending_grants + current_grants for grant in grants: grant.update( award_start_date="{2}/{1}/{0}".format( grant["begin_day"], month_to_int(grant["begin_month"]), grant["begin_year"], ), award_end_date="{2}/{1}/{0}".format( grant["end_day"], month_to_int(grant["end_month"]), grant["end_year"], ), ) badids = [ i["_id"] for i in current_grants if not i.get('cpp_info').get('cppflag', "") ] iter = copy(current_grants) for grant in iter: if grant["_id"] in badids: current_grants.remove(grant) piname = HumanName(pi["name"]) outfile = "current-pending-{}-{}".format(grp, piname.last.lower()) self.render( "current_pending.tex", outfile + ".tex", pi=pi, pending=pending_grants, current=current_grants, pi_upper=pi["name"].upper(), group=group, ) self.pdf(outfile)
def latex(self): """Render latex template""" rc = self.rc if not rc.people: raise RuntimeError("ERROR: please rerun specifying --people name") if not rc.from_date: raise RuntimeError("ERROR: please rerun specifying --from") build_target = get_id_from_name( all_docs_from_collection(rc.client, "people"), rc.people[0]) begin_year = int(rc.from_date.split("-")[0]) begin_period = date_parser.parse(rc.from_date).date() pre_begin_period = begin_period - relativedelta(years=1) if rc.to_date: to_date = date_parser.parse(rc.to_date).date() end_period = to_date post_end_period = to_date + relativedelta(years=1) else: end_period = begin_period + relativedelta(years=1) - relativedelta( days=1) post_end_period = begin_period + relativedelta( years=2) - relativedelta(days=1) me = [p for p in self.gtx["people"] if p["_id"] == build_target][0] me["begin_period"] = dt.date.strftime(begin_period, "%m/%d/%Y") me["begin_period"] = dt.date.strftime(begin_period, "%m/%d/%Y") me["pre_begin_period"] = dt.date.strftime(pre_begin_period, "%m/%d/%Y") me["end_period"] = dt.date.strftime(end_period, "%m/%d/%Y") me["post_end_period"] = dt.date.strftime(post_end_period, "%m/%d/%Y") projs = filter_projects(self.gtx["projects"], set([build_target]), group="bg") ######### # highlights ######### for proj in projs: if proj.get('highlights'): proj["current_highlights"] = False for highlight in proj.get('highlights'): highlight_date = dt.date( highlight.get("year"), month_to_int(highlight.get("month", 1)), 1) if highlight_date > begin_period and highlight_date < end_period: highlight["is_current"] = True proj["current_highlights"] = True ######### # current and pending ######### pi = fuzzy_retrieval(self.gtx["people"], ["aka", "name", "_id"], build_target) # pi['initials'] = "SJLB" grants = merge_collections_superior(self.gtx["proposals"], self.gtx["grants"], "proposal_id") for g in grants: for person in g["team"]: rperson = fuzzy_retrieval(self.gtx["people"], ["aka", "name"], person["name"]) if rperson: person["name"] = rperson["name"] if g.get('budget'): amounts = [i.get('amount') for i in g.get('budget')] g['subaward_amount'] = sum(amounts) current_grants = [dict(g) for g in grants if is_current(g)] current_grants, _, _ = filter_grants(current_grants, {pi["name"]}, pi=False, multi_pi=True) pending_grants = [ g for g in self.gtx["proposals"] if g["status"] == "pending" ] for g in pending_grants: for person in g["team"]: rperson = fuzzy_retrieval(self.gtx["people"], ["aka", "name"], person["name"]) if rperson: person["name"] = rperson["name"] pending_grants, _, _ = filter_grants(pending_grants, {pi["name"]}, pi=False, multi_pi=True) grants = pending_grants + current_grants for grant in grants: grant.update( award_start_date="{2}/{1}/{0}".format( grant["begin_day"], month_to_int(grant["begin_month"]), grant["begin_year"], ), award_end_date="{2}/{1}/{0}".format( grant["end_day"], month_to_int(grant["end_month"]), grant["end_year"], ), ) badids = [ i["_id"] for i in current_grants if not i['cpp_info'].get('cppflag', "") ] iter = copy(current_grants) for grant in iter: if grant["_id"] in badids: current_grants.remove(grant) ######### # end current and pending ######### ######### # advising ######### undergrads = filter_employment_for_advisees(self.gtx["people"], begin_period, "undergrad") masters = filter_employment_for_advisees(self.gtx["people"], begin_period, "ms") currents = filter_employment_for_advisees(self.gtx["people"], begin_period, "phd") graduateds = filter_employment_for_advisees( self.gtx["people"], begin_period.replace(year=begin_year - 5), "phd") postdocs = filter_employment_for_advisees(self.gtx["people"], begin_period, "postdoc") visitors = filter_employment_for_advisees(self.gtx["people"], begin_period, "visitor-unsupported") iter = deepcopy(graduateds) for g in iter: if g.get("active"): graduateds.remove(g) iter = deepcopy(currents) for g in iter: if not g.get("active"): currents.remove(g) ###################### # service ##################### mego = deepcopy(me) dept_service = filter_service([mego], begin_period, "department") mego = deepcopy(me) school_service = filter_service([mego], begin_period, "school") mego = deepcopy(me) uni_service = filter_service([mego], begin_period, "university") uni_service.extend(school_service) mego = deepcopy(me) prof_service = filter_service([mego], begin_period, "profession") mego = deepcopy(me) outreach = filter_service([mego], begin_period, "outreach") mego = deepcopy(me) lab = filter_facilities([mego], begin_period, "research") mego = deepcopy(me) shared = filter_facilities([mego], begin_period, "shared") mego = deepcopy(me) fac_other = filter_facilities([mego], begin_period, "other") mego = deepcopy(me) fac_teaching = filter_facilities([mego], begin_period, "teaching") mego = deepcopy(me) fac_wishlist = filter_facilities([mego], begin_period, "research_wish", verbose=False) mego = deepcopy(me) tch_wishlist = filter_facilities([mego], begin_period, "teaching_wish") mego = deepcopy(me) curric_dev = filter_activities([mego], begin_period, "teaching") mego = deepcopy(me) other_activities = filter_activities([mego], begin_period, "other") ########################## # Presentation list ########################## keypres = filter_presentations(self.gtx["people"], self.gtx["presentations"], self.gtx["institutions"], build_target, types=["award", "plenary", "keynote"], since=begin_period, before=end_period, statuses=["accepted"]) invpres = filter_presentations(self.gtx["people"], self.gtx["presentations"], self.gtx["institutions"], build_target, types=["invited"], since=begin_period, before=end_period, statuses=["accepted"]) sempres = filter_presentations(self.gtx["people"], self.gtx["presentations"], self.gtx["institutions"], build_target, types=["colloquium", "seminar"], since=begin_period, before=end_period, statuses=["accepted"]) declpres = filter_presentations(self.gtx["people"], self.gtx["presentations"], self.gtx["institutions"], build_target, types=["all"], since=begin_period, before=end_period, statuses=["declined"]) ######################### # Awards ######################### ahs = awards(me, since=begin_period) ######################## # Publications ######################## names = frozenset(me.get("aka", []) + [me["name"]]) pubs = filter_publications(all_docs_from_collection( rc.client, "citations"), names, reverse=True, bold=False, since=begin_period) bibfile = make_bibtex_file(pubs, pid=me["_id"], person_dir=self.bldir) articles = [prc for prc in pubs if prc.get("entrytype") in "article"] nonarticletypes = [ "book", "inbook", "proceedings", "inproceedings", "incollection", "unpublished", "phdthesis", "misc" ] nonarticles = [ prc for prc in pubs if prc.get("entrytype") in nonarticletypes ] peer_rev_conf_pubs = [prc for prc in pubs if prc.get("peer_rev_conf")] pubiter = deepcopy(pubs) for prc in pubiter: if prc.get("peer_rev_conf"): peer_rev_conf_pubs = prc pubs.pop(prc) ############## # TODO: add Current Projects to Research summary section ############## ############# # IP ############# patents = filter_patents(self.gtx["patents"], self.gtx["people"], build_target, since=begin_period) licenses = filter_licenses(self.gtx["patents"], self.gtx["people"], build_target, since=begin_period) ############# # hindex ############# hindex = sorted(me["hindex"], key=doc_date_key).pop() ######################### # render ######################### self.render( "columbia_annual_report.tex", "billinge-ann-report.tex", pi=pi, p=me, projects=projs, pending=pending_grants, current=current_grants, undergrads=undergrads, masters=masters, currentphds=currents, graduatedphds=graduateds, postdocs=postdocs, visitors=visitors, dept_service=dept_service, uni_service=uni_service, prof_service=prof_service, outreach=outreach, lab=lab, shared=shared, facilities_other=fac_other, fac_teaching=fac_teaching, fac_wishlist=fac_wishlist, tch_wishlist=tch_wishlist, curric_dev=curric_dev, other_activities=other_activities, keypres=keypres, invpres=invpres, sempres=sempres, declpres=declpres, sentencecase=sentencecase, monthstyle=month_fullnames, ahs=ahs, pubs=articles, nonarticles=nonarticles, peer_rev_conf_pubs=peer_rev_conf_pubs, bibfile=bibfile, patents=patents, licenses=licenses, hindex=hindex, ) self.pdf("billinge-ann-report")
def mdy(month, day, year, **kwargs): return "{}/{}/{}".format( str(month_to_int(month)).zfill(2), str(day).zfill(2), str(year)[-2:])
def mdy_date(month, day, year, **kwargs): if isinstance(month, str): month = month_to_int(month) return datetime.date(year, month, day)
def has_started(sd, sm, sy): s = '{}/{}/{}'.format(sd, month_to_int(sm), sy) start = time.mktime(datetime.datetime.strptime(s, "%d/%m/%Y").timetuple()) return start < time.time()
def test_month_to_int(input, expected): assert month_to_int(input) == expected
def has_finished(ed, em, ey): e = '{}/{}/{}'.format(ed, month_to_int(em), ey) end = time.mktime(datetime.datetime.strptime(e, "%d/%m/%Y").timetuple()) return end < time.time()
def date_to_rfc822(y, m, d=1): """Converts a date to an RFC 822 formatted string.""" d = datetime(int(y), month_to_int(m), int(d)) return email.utils.format_datetime(d)
def latex(self): """Render latex template""" # just a reminder placeholder how to access these. These # print statements will be removed when the builder is updated # to use them! print(self.rc.from_date) print(self.rc.to_date) print(self.rc.people) print(self.rc.grants) for group in self.gtx["groups"]: grp = group["_id"] grpmember_ids = group_member_ids(self.gtx['people'], grp) for member in grpmember_ids: presentations = deepcopy(self.gtx["presentations"]) types = ["all"] # types = ['invited'] #statuses = ["all"] statuses = ['accepted'] firstclean = list() secondclean = list() presclean = list() # build the filtered collection # only list the talk if the group member is an author for pres in presentations: pauthors = pres["authors"] if isinstance(pauthors, str): pauthors = [pauthors] authors = [ fuzzy_retrieval( self.gtx["people"], ["aka", "name", "_id"], author, case_sensitive=False, ) for author in pauthors ] authorids = [ author["_id"] for author in authors if author is not None ] if member in authorids: firstclean.append(pres) # only list the presentation if it is accepted for pres in firstclean: if pres["status"] in statuses or "all" in statuses: secondclean.append(pres) # only list the presentation if it is invited for pres in secondclean: if pres["type"] in types or "all" in types: presclean.append(pres) # build author list for pres in presclean: pauthors = pres["authors"] if isinstance(pauthors, str): pauthors = [pauthors] pres["authors"] = [ author if fuzzy_retrieval( self.gtx["people"], ["aka", "name", "_id"], author, case_sensitive=False, ) is None else fuzzy_retrieval( self.gtx["people"], ["aka", "name", "_id"], author, case_sensitive=False, )["name"] for author in pauthors ] authorlist = ", ".join(pres["authors"]) pres["authors"] = authorlist # fixme: make this a more generic date loading function? if pres.get("begin_month"): pres["begin_month"] = month_to_int(pres["begin_month"]) else: sys.exit("no begin_month in {}".format(pres["_id"])) if not pres.get("begin_year"): sys.exit("no begin_year in {}".format(pres["_id"])) if pres.get("begin_day"): pres["begin_day"] = pres["begin_day"] else: sys.exit("no begin_day in {}".format(pres["_id"])) pres["date"] = datetime.date( pres["begin_year"], pres["begin_month"], pres["begin_day"], ) for day in ["begin_day", "end_day"]: pres["{}_suffix".format(day)] = number_suffix( pres.get(day, None)) if "institution" in pres: inst = pres["institution"] try: pres["institution"] = fuzzy_retrieval( self.gtx["institutions"], ["aka", "name", "_id"], pres["institution"], case_sensitive=False, ) if pres["institution"] is None: print( "WARNING: institution {} in {} not found in " "institutions.yml. Preslist will build " "but to avoid errors please add and " "rerun".format(inst, pres["_id"])) pres["institution"] = { "_id": inst, "department": { "name": "" } } except: print("no institute {} in institutions collection". format(inst)) pres["institution"] = { "_id": inst, "department": { "name": "" } } # sys.exit( # "ERROR: institution {} not found in " # "institutions.yml. Please add and " # "rerun".format(pres["institution"]) # ) if "department" in pres: try: pres["department"] = pres["institution"][ "departments"][pres["department"]] except: print( "WARNING: department {} not found in" " {} in institutions.yml. Pres list will" " build but please check this entry carefully and" " please add the dept to the institution!". format( pres["department"], pres["institution"]["_id"], )) else: pres["department"] = {"name": ""} if len(presclean) > 0: presclean = sorted( presclean, key=lambda k: k.get("date", None), reverse=True, ) outfile = "presentations-" + grp + "-" + member pi = [ person for person in self.gtx["people"] if person["_id"] is member ][0] self.render( "preslist.tex", outfile + ".tex", pi=pi, presentations=presclean, sentencecase=sentencecase, monthstyle=month_fullnames, ) self.pdf(outfile)
def latex(self): """Render latex template""" rc = self.rc if not rc.people: raise RuntimeError("ERROR: please rerun specifying --people name") if not rc.from_date: raise RuntimeError("ERROR: please rerun specifying --from") build_target = get_id_from_name( all_docs_from_collection(rc.client, "people"), rc.people[0]) begin_year = int(rc.from_date.split("-")[0]) begin_month = int(rc.from_date.split("-")[1]) pre_begin_year = begin_year - 1 end_year = begin_year + 1 end_month = begin_month - 1 post_end_year = begin_year + 2 begin_period = dt.date(begin_year, begin_month, 1) pre_begin_period = dt.date(pre_begin_year, begin_month, 1) end_period = dt.date(end_year, end_month, 28) post_end_period = dt.date(post_end_year, end_month, 28) me = [p for p in self.gtx["people"] if p["_id"] == build_target][0] me["begin_period"] = dt.date.strftime(begin_period, "%m/%d/%Y") me["begin_period"] = dt.date.strftime(begin_period, "%m/%d/%Y") me["pre_begin_period"] = dt.date.strftime(pre_begin_period, "%m/%d/%Y") me["end_period"] = dt.date.strftime(end_period, "%m/%d/%Y") me["post_end_period"] = dt.date.strftime(post_end_period, "%m/%d/%Y") projs = filter_projects( self.gtx["projects"], set([build_target]), group="bg" ) ######### # highlights ######### for proj in projs: if proj.get('highlights'): proj["current_highlights"] = False for highlight in proj.get('highlights'): highlight_date = dt.date(highlight.get("year"), month_to_int(highlight.get("month", 1)), 1) if highlight_date > begin_period and highlight_date < end_period: highlight["is_current"] = True proj["current_highlights"] = True ######### # current and pending ######### ######### # end current and pending ######### ######### # advising ######### undergrads = filter_employment_for_advisees(self.gtx["people"], begin_period, "undergrad") masters = filter_employment_for_advisees(self.gtx["people"], begin_period, "ms") currents = filter_employment_for_advisees(self.gtx["people"], begin_period, "phd") graduateds = filter_employment_for_advisees(self.gtx["people"], begin_period.replace( year=begin_year - 5), "phd") postdocs = filter_employment_for_advisees(self.gtx["people"], begin_period, "postdoc") visitors = filter_employment_for_advisees(self.gtx["people"], begin_period, "visitor-unsupported") iter = deepcopy(graduateds) for g in iter: if g.get("active"): graduateds.remove(g) iter = deepcopy(currents) for g in iter: if not g.get("active"): currents.remove(g) ###################### # service ##################### mego = deepcopy(me) dept_service = filter_service([mego], begin_period, "department") mego = deepcopy(me) school_service = filter_service([mego], begin_period, "school") mego = deepcopy(me) uni_service = filter_service([mego], begin_period, "university") uni_service.extend(school_service) mego = deepcopy(me) prof_service = filter_service([mego], begin_period, "profession") mego = deepcopy(me) outreach = filter_service([mego], begin_period, "outreach") mego = deepcopy(me) lab = filter_facilities([mego], begin_period, "research") mego = deepcopy(me) shared = filter_facilities([mego], begin_period, "shared") mego = deepcopy(me) fac_other = filter_facilities([mego], begin_period, "other") mego = deepcopy(me) fac_teaching = filter_facilities([mego], begin_period, "teaching") mego = deepcopy(me) fac_wishlist = filter_facilities([mego], begin_period, "research_wish", verbose=False) mego = deepcopy(me) tch_wishlist = filter_facilities([mego], begin_period, "teaching_wish") mego = deepcopy(me) curric_dev = filter_activities([mego], begin_period, "teaching") mego = deepcopy(me) other_activities = filter_activities([mego], begin_period, "other") ########################## # Presentation list ########################## keypres = filter_presentations(self.gtx["people"], self.gtx["presentations"], self.gtx["institutions"], build_target, types=["award", "plenary", "keynote"], since=begin_period, before=end_period, statuses=["accepted"]) invpres = filter_presentations(self.gtx["people"], self.gtx["presentations"], self.gtx["institutions"], build_target, types=["invited"], since=begin_period, before=end_period, statuses=["accepted"]) sempres = filter_presentations(self.gtx["people"], self.gtx["presentations"], self.gtx["institutions"], build_target, types=["colloquium", "seminar"], since=begin_period, before=end_period, statuses=["accepted"]) declpres = filter_presentations(self.gtx["people"], self.gtx["presentations"], self.gtx["institutions"], build_target, types=["all"], since=begin_period, before=end_period, statuses=["declined"]) ######################### # Awards ######################### ahs = awards(me, since=begin_period) ######################## # Publications ######################## names = frozenset(me.get("aka", []) + [me["name"]]) pubs = filter_publications( all_docs_from_collection(rc.client, "citations"), names, reverse=True, bold=False, since=begin_period ) bibfile = make_bibtex_file( pubs, pid=me["_id"], person_dir=self.bldir ) articles = [prc for prc in pubs if prc.get("entrytype") in "article"] nonarticletypes = ["book", "inbook", "proceedings", "inproceedings", "incollection", "unpublished", "phdthesis", "misc"] nonarticles = [prc for prc in pubs if prc.get("entrytype") in nonarticletypes] peer_rev_conf_pubs = [prc for prc in pubs if prc.get("peer_rev_conf")] pubiter = deepcopy(pubs) for prc in pubiter: if prc.get("peer_rev_conf"): peer_rev_conf_pubs = prc pubs.pop(prc) ############## # TODO: add Current Projects to Research summary section ############## ############# # IP ############# patents = filter_patents(self.gtx["patents"], self.gtx["people"], build_target, since=begin_period) licenses = filter_licenses(self.gtx["patents"], self.gtx["people"], build_target, since=begin_period) ############# # hindex ############# hindex = sorted(me["hindex"], key=doc_date_key).pop() ######################### # render ######################### # "C:/Users/simon/scratch/billinge-ann-report.tex", self.render( "columbia_annual_report.tex", "billinge-ann-report.tex", pi=pi, p=me, projects=projs, pending=pending_grants, current=current_grants, undergrads=undergrads, masters=masters, currentphds=currents, graduatedphds=graduateds, postdocs=postdocs, visitors=visitors, dept_service=dept_service, uni_service=uni_service, prof_service=prof_service, outreach=outreach, lab=lab, shared=shared, facilities_other=fac_other, fac_teaching=fac_teaching, fac_wishlist=fac_wishlist, tch_wishlist=tch_wishlist, curric_dev=curric_dev, other_activities=other_activities, keypres=keypres, invpres=invpres, sempres=sempres, declpres=declpres, sentencecase=sentencecase, monthstyle=month_fullnames, ahs=ahs, pubs=articles, nonarticles=nonarticles, peer_rev_conf_pubs=peer_rev_conf_pubs, bibfile=bibfile, patents=patents, licenses=licenses, hindex=hindex, ) self.pdf("billinge-ann-report")