pylhc / Beta-Beat.src

Many scripts and files for beam optics simulations & measurements in the LHC
https://pylhc.github.io/Beta-Beat.src/
7 stars 10 forks source link

tfs_pandas header parser for multi-word headers #123

Closed JoschD closed 6 years ago

JoschD commented 6 years ago

I got tfs files, e.g. error tables, that have headers with more than one word as names (see below). These can not be read by tfs_pandas as it assumes that the third part (split by spaces) is already the data-type (hence it raises TfsFormatError).

Hence, maybe join all parts until one starts with % ?

------------------------------------- Example Header -------------------------------------

@ Error sources %20s "MAGNETIC_FIELD,POWER" @ Magnet types %102s "MB,MBRB,MBRC,MBRS,MBW,MBX,MBXW,MQ,MQM,MQMC,MQML,MQS,MQSX,MQT,MQTLH,MQTLI,MQWA,MQWB,MQXA,MQXB,MQY,OTHER" @ Multipoles %69s "a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11" @ s (m) %3s "ALL" @ Sectors %3s "ALL" @ Options %32s "FIDEL-DYNAMIC-MODEL,B2-CLOCKWISE" @ Conventions %178s "Multipoles for both beams expressed in local measurement ref frame, s-axis: CS->NCS, x-axis: horisontal, right-hand axis when looking in CS->NCS direction, y-axis: up in sky (-g)" @ Cycle state %16s "FLAT-TOP SQUEEZE" @ Squeeze state of IPs with matched optics @ Beta IP1 (m) %le 0.40 @ Beta IP2 (m) %le 10.00 @ Beta IP5 (m) %le 0.40 @ Beta IP8 (m) %le 3.00 @ Previous cycle %9s "PRE-CYCLE" @ Energy (TeV) %le 6.500 @ Charge (e) %le 1 @ FiDeL model parameters updated %08s 01/07/14 @ LHC slot allocation updated %08s 01/06/14

JoschD commented 6 years ago

Question: Should it be allowed to have just comments in the header, like (see above): @ Squeeze state of IPs with matched optics

??

awegsche commented 6 years ago

A few comments on that:

Also the important phase advance would profit from multiword headers because the header would be Element1 to Element2 using BPM1 and BPM2 %s "delta +- error; delta_deg +- error_deg" which at the moment I avoid by using double underscores (because one alone can appear in the BPM name) Element1toElement2usingBPM1andBPM2 %s "delta +- error; delta_deg +- error_deg"

On 23.04.2018 11:53, JoschD wrote:

Question: Should it be allowed to have just comments in the header, like (see above): /@ Squeeze state of IPs with matched optics/

??

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pylhc/Beta-Beat.src/issues/123#issuecomment-383519794, or mute the thread https://github.com/notifications/unsubscribe-auth/AT2pMmkEpW2fw2FE0gyYRxDbtqJ_GnN6ks5traR_gaJpZM4Tfiaa.

JoschD commented 6 years ago

@awegsche no need for underscores any more, you can use spaces.

I close this issue with the hint to Andreas solution to identify comments as such by e.g. @ comment %s "Comment"