1 | #! /usr/bin/env python |
---|
2 | #-*- coding: utf8 -*- |
---|
3 | import ads |
---|
4 | import numpy as np |
---|
5 | import os |
---|
6 | |
---|
7 | ########################################## |
---|
8 | # Aymeric SPIGA |
---|
9 | # Laboratoire de Météorologie Dynamique |
---|
10 | # 15-20/12/2013. teams 01/2014. |
---|
11 | ########################################## |
---|
12 | |
---|
13 | #### SETTINGS |
---|
14 | titpre = "<CENTER><H2><EM><font color='#B8860B;'>" # title prefix |
---|
15 | titsuf = "</font></EM></H2></CENTER>" # title suffix |
---|
16 | anneec = 2014 # last year to include |
---|
17 | oneyear = None |
---|
18 | #oneyear = 2013 |
---|
19 | usercond = None |
---|
20 | usercond = ''' -c 'not journal:"Discussions"' ''' # fixes the EGU Discussions journals problem |
---|
21 | #### |
---|
22 | |
---|
23 | ### FOLDER |
---|
24 | folder = "/home/marshttp/www-mars/publmdall" |
---|
25 | if oneyear is not None: folder = folder + str(oneyear) |
---|
26 | |
---|
27 | ### CLEAN |
---|
28 | os.system('rm -rf '+folder) |
---|
29 | |
---|
30 | ### GET TEAM LIST and SIZE |
---|
31 | tnom,tprenom,tinitiales,tequipe,tanneedeb,tanneefin,taltnom = np.loadtxt("listpeople.txt",delimiter=";",dtype='string',unpack=True,skiprows=3,comments="#") |
---|
32 | |
---|
33 | ### LOOP on EACH TEAM (and add a combined list for all TEAMS) |
---|
34 | ll = list(set(tequipe)) ; ll.append('all') ; ll = ll[::-1] |
---|
35 | for eqeq in ll: |
---|
36 | |
---|
37 | ### GET ONLY MEMBERS OF THE TEAM |
---|
38 | if eqeq != 'all': |
---|
39 | w = np.where(tequipe==eqeq) |
---|
40 | nom = tnom[w] ; prenom = tprenom[w] ; initiales = tinitiales[w] ; equipe = tequipe[w] |
---|
41 | anneedeb = tanneedeb[w] ; anneefin = tanneefin[w] ; altnom = taltnom[w] |
---|
42 | else: |
---|
43 | nom = tnom ; prenom = tprenom ; initiales = tinitiales ; equipe = tequipe |
---|
44 | anneedeb = tanneedeb ; anneefin = tanneefin ; altnom = taltnom |
---|
45 | ntot = nom.size |
---|
46 | |
---|
47 | ### PREPARE ADS LINK |
---|
48 | # 1. generic parts |
---|
49 | adslink1="http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?db_key=AST&db_key=PHY&db_key=PRE&qform=PHY&arxiv_sel=astro-ph&arxiv_sel=cond-mat&arxiv_sel=cs&arxiv_sel=gr-qc&arxiv_sel=hep-ex&arxiv_sel=hep-lat&arxiv_sel=hep-ph&arxiv_sel=hep-th&arxiv_sel=math&arxiv_sel=math-ph&arxiv_sel=nlin&arxiv_sel=nucl-ex&arxiv_sel=nucl-th&arxiv_sel=physics&arxiv_sel=quant-ph&arxiv_sel=q-bio&aut_xct=YES&aut_logic=OR&author=" |
---|
50 | adslink2="+&ned_query=YES&sim_query=YES&start_mon=&start_year=&end_mon=&end_year=&ttl_logic=OR&title=&txt_logic=OR&text=&nr_to_return=1999&start_nr=1&jou_pick=NO&ref_stems=" |
---|
51 | if oneyear is not None: |
---|
52 | adslink2="+&ned_query=YES&sim_query=YES&start_mon=&start_year="+str(oneyear)+"&end_mon=&end_year="+str(oneyear)+"&ttl_logic=OR&title=&txt_logic=OR&text=&nr_to_return=1999&start_nr=1&jou_pick=NO&ref_stems=" |
---|
53 | adslink3="&data_and=ALL&group_and=ALL&start_entry_day=&start_entry_mon=&start_entry_year=&end_entry_day=&end_entry_mon=&end_entry_year=&min_score=&sort=SCORE&data_type=BIBTEXPLUS&aut_syn=YES&ttl_syn=YES&txt_syn=YES&aut_wt=1.0&ttl_wt=0.3&txt_wt=3.0&aut_wgt=YES&obj_wgt=YES&ttl_wgt=YES&txt_wgt=YES&ttl_sco=YES&txt_sco=YES&version=1" |
---|
54 | # 2. author list |
---|
55 | st=adslink1 ; st2 = "" |
---|
56 | tf = open("ads.testauthor", 'w') # this is just for testing ADS outside the script |
---|
57 | for iii in range(ntot): |
---|
58 | st = st + nom[iii].split()[0].replace('é',"%C3%A9")\ |
---|
59 | +"++%2C++"\ |
---|
60 | + prenom[iii].split()[0].replace('é',"%C3%A9")\ |
---|
61 | +"++%3B++"\ |
---|
62 | + nom[iii].split()[0].replace('é',"%C3%A9")\ |
---|
63 | +"++%2C++"\ |
---|
64 | + initiales[iii].split()[0].replace('é',"%C3%A9")\ |
---|
65 | +"++%3B++" |
---|
66 | st2 = st2 + nom[iii] + " , " + prenom[iii] + " ; " + nom[iii] + " , " + initiales[iii] + " ; " |
---|
67 | if altnom[iii].split()[0] != "-": |
---|
68 | st = st + altnom[iii].split()[0].replace('é',"%C3%A9")\ |
---|
69 | +"++%2C++"\ |
---|
70 | + prenom[iii].split()[0].replace('é',"%C3%A9")\ |
---|
71 | +"++%3B++"\ |
---|
72 | + altnom[iii].split()[0].replace('é',"%C3%A9")\ |
---|
73 | +"++%2C++"\ |
---|
74 | + initiales[iii].split()[0].replace('é',"%C3%A9")\ |
---|
75 | +"++%3B++" |
---|
76 | st2 = st2 + altnom[iii] + " , " + prenom[iii] + " ; " + altnom[iii] + " , " + initiales[iii] + " ; " |
---|
77 | st=st+adslink2 |
---|
78 | tf.write(st2) |
---|
79 | tf.close() |
---|
80 | # 3. journal list |
---|
81 | jn = "" |
---|
82 | f = open("listjournals.txt", 'r') |
---|
83 | for line in f: |
---|
84 | jj = line.strip().replace("&","%26") |
---|
85 | jn = jn + jj + "+" |
---|
86 | st=st+jn+adslink3 |
---|
87 | # 4. write final result |
---|
88 | dalink = folder+eqeq.strip()+".link" |
---|
89 | os.system('rm -rf '+dalink) |
---|
90 | daf = open(dalink, 'w') |
---|
91 | daf.write(st) |
---|
92 | daf.close() |
---|
93 | |
---|
94 | ### RETRIEVE COMPLETE BIBTEX FILE |
---|
95 | ads.makepage('lmd_dummy',retrieve=True,linkads=dalink,customcond=usercond,verbose=False) |
---|
96 | |
---|
97 | ### LOOP ON NAMES |
---|
98 | miny = 9999 ; maxy = -9999 ; lk = "<br>Author:" |
---|
99 | for iii in range(ntot): |
---|
100 | # 1. get and prepare various components |
---|
101 | danom = nom[iii].strip() ; daprenom = prenom[iii].strip() |
---|
102 | dayears = int(anneedeb[iii]) ; dayeare = int(anneefin[iii]) |
---|
103 | daini = initiales[iii].split()[0] |
---|
104 | if usercond is None: cc = ''' -c ' ''' |
---|
105 | else: cc = usercond + ''' -c ' ''' |
---|
106 | cc = cc + ''' author:"'''+danom+'''" ''' |
---|
107 | if altnom[iii].split()[0] != "-": |
---|
108 | danomalt = altnom[iii].split()[0] |
---|
109 | cc = cc + ''' or author:"'''+danomalt+'''" ''' |
---|
110 | cc = cc+''' ' ''' |
---|
111 | # -- if year start 0000 and year end 0000 do not do anything |
---|
112 | if dayears + dayeare != 0: |
---|
113 | if dayears == 0: dayears = anneec |
---|
114 | if dayeare == 0: dayeare = anneec |
---|
115 | # 2. info |
---|
116 | print danom+"-"+daprenom+"-"+str(dayears)+"-"+str(dayeare) |
---|
117 | # 3. make page |
---|
118 | if oneyear is None: ly = range(dayeare,dayears-1,-1) |
---|
119 | else: ly = [oneyear] |
---|
120 | ads.makepage('lmd_'+danom.replace(" ", ""),\ |
---|
121 | retrieve = False,\ |
---|
122 | customcond = cc,\ |
---|
123 | listyear = ly,\ |
---|
124 | linkads = dalink,\ |
---|
125 | title = titpre+daprenom+" "+danom+titsuf,\ |
---|
126 | printnum = True,\ |
---|
127 | verbose = False,\ |
---|
128 | target = folder) |
---|
129 | # 4. get intervals of years for the whole lab |
---|
130 | if oneyear is None: |
---|
131 | if dayears < miny: miny = dayears |
---|
132 | if dayeare > maxy: maxy = dayeare |
---|
133 | # 5. get authors link list |
---|
134 | lk = lk + ''' <a href="lmd_'''+danom.replace(" ", "")+'''.html">'''+daini+" "+danom.replace('é',"é")+"</a> /" |
---|
135 | |
---|
136 | ### MAKE FINAL PAGE |
---|
137 | if oneyear is None: ly = range(maxy,miny-1,-1) |
---|
138 | else: ly = [oneyear] |
---|
139 | ads.makepage('lmd_'+eqeq.strip(),\ |
---|
140 | retrieve = False,\ |
---|
141 | listyear = ly,\ |
---|
142 | linkads = dalink,\ |
---|
143 | title = "<CENTER><H2><EM><font color='#B8860B;'>Peer-reviewed publications for team "+eqeq.strip()+"</font></EM></H2></CENTER>",\ |
---|
144 | addlink = lk,\ |
---|
145 | customcond = usercond,\ |
---|
146 | printnum = True,\ |
---|
147 | target = folder) |
---|
148 | |
---|
149 | ### CLEAN |
---|
150 | os.system('rm -rf *dummy*') |
---|
151 | os.system('rm -rf '+folder+'*.link*') |
---|
152 | |
---|