def generate_unique_name_core(instr, filekind, extension, now=None): """Given an arbitrarily named filename (which must correctly define it's format, e.g. .fits) generate and return a unique enhanced CDBS-style name which incorporates a timestamp, and instrument id character, and a filetype suffix. Character 1 : Year [z=2015, 0=2016, 1= 2017, etc.] Character 2 : Month [1-9, a-c] Character 3 : Day [1-9, a-s(28), t(29), u(30), v(31)] Character 4-5: UT Hour [00 - 23] Character 6-7: UT Minute [00 - 59] Character 8 : UT Seconds [0-9, a-t (~2 second intervals)] Character 9 : Instrument Designation [j=ACS, i=WFC3, o=STIS, l=COS, u=WFPC2, n=NICMOS, m=MULTI, m=SYNPHOT] """ if now is None: # delay to ensure timestamp is unique. time.sleep(2) timeid = generate_timestamp(now) suffix = "_" + filekind_to_suffix(instr, filekind) instr_char = siname.instrument_to_id_char(instr) return timeid + instr_char + suffix + extension