From 06556ae52348082c8f9515969ad99094d3b249a3 Mon Sep 17 00:00:00 2001 From: FusRoman <46221629+FusRoman@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:27:05 +0200 Subject: [PATCH] update tags to be more persistent in time (#120) * update tags to be more persistentin time * pep8 requirements * update test cli data according to the new tags * remove tags issue * pep8 requirements * bump to 0.15.0 --- bin/utils_cli.py | 7 +-- fink_fat/__init__.py | 2 +- fink_fat/others/id_tags.py | 46 ++++++++---------- .../fink_fat_out_test/mpc/orbital.parquet | Bin 16935 -> 17020 bytes .../mpc/trajectory_orb.parquet | Bin 35481 -> 35570 bytes fink_fat/test/cli_test/test_cli.py | 8 --- fink_fat/test/utils_cli_test_orb.parquet | Bin 3659 -> 3734 bytes fink_fat/test/utils_cli_test_traj.parquet | Bin 3122 -> 3208 bytes 8 files changed, 24 insertions(+), 39 deletions(-) diff --git a/bin/utils_cli.py b/bin/utils_cli.py index 7d89ecfe..c52f6dbc 100644 --- a/bin/utils_cli.py +++ b/bin/utils_cli.py @@ -433,7 +433,7 @@ def assig_tags(orb_df, traj_orb_df, start_tags): >>> orb = pd.DataFrame({ ... "trajectory_id": [0, 1, 2, 3, 4, 5], ... "a": [1, 1.5, 1.6, 2.8, 35.41, 265.32], - ... "ref_epoch": [0, 2, 3, 5, 4, 1] + ... "ref_epoch": [2460235.42, 2460412.42, 2460842.42, 2460137.42, 2460131.42, 2460095.42] ... }) >>> traj = pd.DataFrame({ ... "trajectory_id": [0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 3, 3, 4, 5, 3, 5, 4, 5, 4, 3, 1, 2, 3, 4, 5, 5, 2], @@ -445,15 +445,12 @@ def assig_tags(orb_df, traj_orb_df, start_tags): >>> orb_test = pd.read_parquet("fink_fat/test/utils_cli_test_orb.parquet") >>> traj_test = pd.read_parquet("fink_fat/test/utils_cli_test_traj.parquet") - >>> orb_test["ssoCandId"] = orb_test["ssoCandId"].str.replace("2022", str(datetime.date.today().year), regex=False) - >>> traj_test["ssoCandId"] = traj_test["ssoCandId"].str.replace("2022", str(datetime.date.today().year), regex=False) - >>> assert_frame_equal(orb_test, new_orb) >>> assert_frame_equal(traj_test, new_traj) """ orb_df = orb_df.sort_values("ref_epoch") - all_tags = generate_tags(start_tags, start_tags + len(orb_df)) + all_tags = generate_tags(start_tags, start_tags + len(orb_df), orb_df["ref_epoch"]) int_id_to_tags = { tr_id: tag for tr_id, tag in zip(orb_df["trajectory_id"], all_tags) } diff --git a/fink_fat/__init__.py b/fink_fat/__init__.py index e0b98f4e..6acad165 100644 --- a/fink_fat/__init__.py +++ b/fink_fat/__init__.py @@ -12,4 +12,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.14.0" +__version__ = "0.15.0" diff --git a/fink_fat/others/id_tags.py b/fink_fat/others/id_tags.py index a6f1ffa3..df51e697 100644 --- a/fink_fat/others/id_tags.py +++ b/fink_fat/others/id_tags.py @@ -1,20 +1,24 @@ -import datetime +import numpy as np +from astropy.time import Time -def int_to_tags(traj_id): + +def int_to_tags(traj_id, jd): """ Convert an integer into a Fink-FAT trajectory identifier. The identifier format is : "FFYYYYXXXXXXX" where 'FF' is for 'Fink-FAT', - 'YYYY' is the full year (2022), + 'DDMMYYYY' is the full date (01012022), and 'XXXXXXX' is the number of trajectories since the beginning of the year in the base-26. Parameters ---------- traj_id : integer trajectories identifier as an integer + jd : float + the discovery date of the trajectory Returns ------- @@ -23,20 +27,12 @@ def int_to_tags(traj_id): Examples -------- - >>> r = int_to_tags(15) - >>> test_value = 'FF{}aaaaaap'.format(datetime.date.today().year) - >>> test_value == r - True - - >>> r =int_to_tags(27) - >>> test_value = 'FF{}aaaaabb'.format(datetime.date.today().year) - >>> test_value == r - True - - >>> r = int_to_tags(652) - >>> test_value = 'FF{}aaaaazc'.format(datetime.date.today().year) - >>> test_value == r - True + >>> int_to_tags(15, 2460135.98) + 'FF10072023aaaaaap' + >>> int_to_tags(27, 2460135.98) + 'FF10072023aaaaabb' + >>> int_to_tags(652, 2460135.98) + 'FF10072023aaaaazc' """ res_tag = "" for _ in range(7): @@ -46,10 +42,11 @@ def int_to_tags(traj_id): res_tag += chr(r + 97) traj_id = q - return "FF" + str(datetime.date.today().year) + res_tag[::-1] + discovery = Time(jd, format="jd").datetime + return "FF{:02d}{:02d}{}{}".format(discovery.day, discovery.month, discovery.year, res_tag[::-1]) -def generate_tags(begin, end): +def generate_tags(begin, end, jd): """ Generate a list of tags between begin and end @@ -60,6 +57,8 @@ def generate_tags(begin, end): start tags end : integer end tags + jd : float list + list of discovery date Returns ------- @@ -68,13 +67,10 @@ def generate_tags(begin, end): Examples -------- - >>> l = generate_tags(3, 6) - >>> year = datetime.date.today().year - >>> test_value = ['FF{}aaaaaad'.format(year), 'FF{}aaaaaae'.format(year), 'FF{}aaaaaaf'.format(year)] - >>> test_value == l - True + >>> generate_tags(3, 6, [2460135.42, 2460137.57, 2460148.72]) + ['FF09072023aaaaaad', 'FF12072023aaaaaae', 'FF23072023aaaaaaf'] """ - return [int_to_tags(i) for i in range(begin, end)] + return [int_to_tags(i, date) for date, i in zip(jd, np.arange(begin, end))] if __name__ == "__main__": # pragma: no cover diff --git a/fink_fat/test/cli_test/fink_fat_out_test/mpc/orbital.parquet b/fink_fat/test/cli_test/fink_fat_out_test/mpc/orbital.parquet index 8a4189897870e1c508890d68bafd3bdee0db2678..2bff40fa993cbe3e3ef293d35bdb39d1342158bf 100644 GIT binary patch delta 2257 zcmZ49!uY3!af6k}63}#KfB!Bn}5{yb11Fnt&n0o`!-NMu5$C2u!)!CSMzRpwYl<=eAWMF zUQdAX+Fjw1w?%f_GrpM~RNQ|_-hGMenMKu?>^1Zz=laeSgElUN(0*ds2nPh4uJBGujn$Vi~;1|}CQ zW>#LByir4B@&raPq7&!&z3tw8*2jrXoU_h8Hkh&h49>*4wbwrI=7vjyAaOc=KGG$X>J-o;dxSLmr<0aD?c@DWUt#H=uGAM&kTa`1|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$_g- z*$bXbP;IXJN14U(MavW4Z6B0*9JYB-<}|MlQd?TTc~NGk=R|(mpl3vOdrgtg$3Sbj z#Qll4N21uwrP$kH^A37DEDFOF61WSPK`Tcw%#fcEbj8C?g@aHZ$CknY1qTn>Ul-g> zgc{`pVVRaKgE2~OaQr1&4{tcKrbklQlgUu;sDh7_wvX?HjJ-&gK{ZgCcIepdHPzw3 zo~CPI#>DZa-8}neI;@(gA@51I4fCz3Ka=(3qkl)F6yvwj$7h=BH1}`|T4O^|5d@J0 z9}`3oL=(gi#1gC^SV<5^5Kpj*;1hxb0xdxzK@veS0iQycN{~jdnqUpVS_0h+j0lZ^ z9sz_AD>Nn4$i@y$$B$%YymVZ_n?e|wz)*~yW_Hr5$IWKU7&EzpC#4h*Hai?2kqOel zOSsGVLqS(A?44+@$Q&cNV9s93q1l|x^s67K_I5dEGXFpPo?N z83K9rv_Nt`3>LQ5K&4AS(n?@8Ak{x4EDX$n-Z66h%#bYj94I7s38)vSu>KrKQ8$PK z_Ft#K2trnuoG$?qg2vhAg*lTLnZE6uEMFq6 zzerZ>1h3kgP0VWR)-V&+J2|mLYV*Xr9#-=8OY^Mw#w>P&O>K{@*tO-GJ4!gkI5=b& J7y=xF3<19Dm&gDB delta 550 zcmew~m1*WwrVUcr_0I%FXR-Q-wlRvb2r)2x=Fs3}U|?`_GcqtTPGn_dNU{@TU`PfL zi69~cM5KaYX>=DC5QmAobE6(RM>?wKtzC?B)bqsmZVHO7X~{pZw4dKvAcmT zc3Qec%i|Y2n1Zo`4Uk6=2tnB7@3~zm|RdIt@lepY#Wc-tBuTR>((%%YeMJ& z836>710zK?KhEoBg=$wPQv2jxCDJ?%pP0pNu&M2_6+5zQ^TQHOF%AY928IB~AVUB= C_JV!@ diff --git a/fink_fat/test/cli_test/test_cli.py b/fink_fat/test/cli_test/test_cli.py index 2cbfd163..7e5189c8 100644 --- a/fink_fat/test/cli_test/test_cli.py +++ b/fink_fat/test/cli_test/test_cli.py @@ -2,7 +2,6 @@ from pandas.testing import assert_frame_equal import shutil import sys -import datetime import traceback import logging @@ -118,13 +117,6 @@ "{}mpc/trajectory_orb.parquet".format(data_test_path) ) - orb_test["ssoCandId"] = orb_test["ssoCandId"].str.replace( - "2022", str(datetime.date.today().year), regex=False - ) - obs_orb_test["ssoCandId"] = obs_orb_test["ssoCandId"].str.replace( - "2022", str(datetime.date.today().year), regex=False - ) - try: assert_frame_equal( old_obs.sort_values("candid").round(decimals=5), diff --git a/fink_fat/test/utils_cli_test_orb.parquet b/fink_fat/test/utils_cli_test_orb.parquet index f061d13f6351fab8466b898a9f0f82cf7be1fa06..39a44f41bde4d9f9096ebc143b9c5a88af4ff3fd 100644 GIT binary patch literal 3734 zcmcgvO>7!h5Po2AAi+{xWf4@UvXFwJ%5j%9I3{Xkzr|h*u}O>*ShlIi?y{J*cNfBs z0jJKbRSs3#OApPlhpLCF>YqWDe9L!nm?qF3MhefzuDKB=yr`zrC<;Wv1-R_e;(i<%8p<<3kyOfymTL4;O0l)fBVY= z7Ta9tj~N$wI^%Mjf9Ukl(Yp^>49w__M=Tyk*5mkGJp}~WICTu!1LrX^cTFi3lxjsT z_YnSL3w`YfJ(>cHxDdAtcXGu1jIs|2itpP`)r70ojOq2PrdDBuX#AE-IR%G#Za3bYXTty(Q%X60u=g zG)dA}G=6mlC{H)f?s~lv7mZ@FXh!3UDesT=&=0QAho=J1tbbxGZc%H!NYD-^a@&x@ zeaeBRW?ZwjH*Me(8KgGI7=`9@IV}e26){325#v-48!qDeGXcuc1vgtLs76s~7c}KS z(F$~-&`bGKTj+gH=<_p>@^PIfSegXWe=~}F({;J5=pyAp)amnfxH{H)Txf{$0R1@B z=h0?>pmqRt+(+c~_yhjU7kC{*FXKLhUVNE_US_hrkKJBR$mM|B%idHNP(=0=U zMyE;ygH1z~D@7#;(neFScKVEpw5P}oLf4gsSQHx~h~Eh+28gT1E;)PSI(Kn7cyx5^ z%&-?hksKd#!Xl0MP|_-5V<|H3!vJHz2?FkD9(?Hn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E$ixkO|rQVWY$+fK#@Ttk%kE zKV`^frX%vei(rbUa=G0?>mZ(rYPkvQ1EMc%HuW*Cc&cLi6zjnEZk`))!Fu5+c@|z% z=A)I;PGN{=7O!abI)(fpmx)s!EfKJad?ExshiB1?rsE_RC-D?BXXd$FSLQOcvoOu* zSh0$1W-CfK8dCEygYYByeH=E(aVS$g)JdLXAr~qL*-DAu9p_Iw>XI{U7lg3w&&mws zP=>@wi8dco5^_y35q+G_Q_r((<(l#y~7xJkH&5ad{z_^^e*flZ4J`Z+q!0V64Fy}pGSJy^aG3&RcJcb;AJ;Xg>h;?U&*$u8q@OJ zs2}tUz|+hRKt@_iYB03NF>0B*HS(9R{ZTI`{_tJmbf9q29ny1-gi*Xh(w{KiAKTBz zW83#dLDa;2tW)4d{j7_jaqSKJ8}Vf00jJPBq2Cpt%VB76wC~xc0y?-yB(w?I@#&}i zS~$c!@dy1ERyrUA9d9Aut97YyudTMODE0ak`a58C*yLAf_xF=OKgU1lr)7k0!oQLK E0(5$tod5s; diff --git a/fink_fat/test/utils_cli_test_traj.parquet b/fink_fat/test/utils_cli_test_traj.parquet index 345d01c8604f587b9f62679bd999be7f6823d41f..d87bad4fa0ebc5ae5d8e0d999909754aed89087a 100644 GIT binary patch delta 941 zcmbVLO>YuW6ura8z|b}U!<)=BESi{*E|9(f2BwLoc|fNf1eDg+;z~aHCA69lKsROE zg_~w}#+@6N#wI4Za^cE9pufR1E;MmvqW3-0sML+VOwQc<-nr+VcQf-+JJusN*_uIo z?mOk^UvpQVKRN}7|x z?gwdgG+FRnA}>%FOD+K%SrL@6Z6jyU6iuZYehJz$L^Egx(~LjrYiwg`(k!N?LSScx z1Pz+gm!PE(A2pK%ps5fmO{pma8e*Ztd6Gz={gLn#%ffubwkKE`Zc&rweib&+O|;Cf zW=UQJpjgWewqNgc{SbdY6(iHS83tL`lwR+Cp>f!D+Qg$;>Km{6#S?!Xihm4VXmmyR z`CBJFf#aK)j;nYbF=zFUgZR@xjQFtm#fko}u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