cheminfo / biologic-converter

MIT License
1 stars 2 forks source link

refactor!: added types, modularize code, make compatible parsers #10

Closed ghost closed 2 years ago

ghost commented 2 years ago

There were parts missing and I think there still probably are, but it may be good to try plotting before more modifications.

This is still a draft. Below I describe a bit further:


It may be useful to check the source branch to see the new dir structure in the source branch.

codecov[bot] commented 2 years ago

Codecov Report

Base: 93.87% // Head: 87.82% // Decreases project coverage by -6.04% :warning:

Coverage data is based on head (7f9a687) compared to base (993d356). Patch coverage: 87.43% of modified lines in pull request are covered.

:exclamation: Current head 7f9a687 differs from pull request most recent head 4d0fb51. Consider uploading reports for the commit 4d0fb51 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #10 +/- ## ========================================== - Coverage 93.87% 87.82% -6.05% ========================================== Files 6 22 +16 Lines 310 427 +117 Branches 62 112 +50 ========================================== + Hits 291 375 +84 - Misses 18 51 +33 Partials 1 1 ``` | [Impacted Files](https://codecov.io/gh/cheminfo/biologic-converter/pull/10?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo) | Coverage Δ | | |---|---|---| | [src/mpr/modules/parseLoop.ts](https://codecov.io/gh/cheminfo/biologic-converter/pull/10/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo#diff-c3JjL21wci9tb2R1bGVzL3BhcnNlTG9vcC50cw==) | `20.00% <20.00%> (ø)` | | | [src/mpr/ids.ts](https://codecov.io/gh/cheminfo/biologic-converter/pull/10/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo#diff-c3JjL21wci9pZHMudHM=) | `46.29% <46.29%> (-25.93%)` | :arrow_down: | | [src/mpr/modules/utility/techniquesAndParams.ts](https://codecov.io/gh/cheminfo/biologic-converter/pull/10/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo#diff-c3JjL21wci9tb2R1bGVzL3V0aWxpdHkvdGVjaG5pcXVlc0FuZFBhcmFtcy50cw==) | `55.55% <55.55%> (ø)` | | | [src/mpr/modules/utility/readType.ts](https://codecov.io/gh/cheminfo/biologic-converter/pull/10/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo#diff-c3JjL21wci9tb2R1bGVzL3V0aWxpdHkvcmVhZFR5cGUudHM=) | `85.71% <85.71%> (ø)` | | | [src/mpt/utility/getNbOfHeaderLines.ts](https://codecov.io/gh/cheminfo/biologic-converter/pull/10/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo#diff-c3JjL21wdC91dGlsaXR5L2dldE5iT2ZIZWFkZXJMaW5lcy50cw==) | `85.71% <85.71%> (ø)` | | | [src/mpr/parseMPR.ts](https://codecov.io/gh/cheminfo/biologic-converter/pull/10/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo#diff-c3JjL21wci9wYXJzZU1QUi50cw==) | `92.00% <92.85%> (-2.98%)` | :arrow_down: | | [src/mpr/modules/utility/getParameters.ts](https://codecov.io/gh/cheminfo/biologic-converter/pull/10/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo#diff-c3JjL21wci9tb2R1bGVzL3V0aWxpdHkvZ2V0UGFyYW1ldGVycy50cw==) | `95.00% <95.00%> (ø)` | | | [src/convert.ts](https://codecov.io/gh/cheminfo/biologic-converter/pull/10/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo#diff-c3JjL2NvbnZlcnQudHM=) | `95.23% <100.00%> (-4.77%)` | :arrow_down: | | [src/mpr/modules/parseData.ts](https://codecov.io/gh/cheminfo/biologic-converter/pull/10/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo#diff-c3JjL21wci9tb2R1bGVzL3BhcnNlRGF0YS50cw==) | `100.00% <100.00%> (ø)` | | | [src/mpr/modules/parseLogs.ts](https://codecov.io/gh/cheminfo/biologic-converter/pull/10/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo#diff-c3JjL21wci9tb2R1bGVzL3BhcnNlTG9ncy50cw==) | `100.00% <100.00%> (ø)` | | | ... and [13 more](https://codecov.io/gh/cheminfo/biologic-converter/pull/10/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo) | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cheminfo)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

ghost commented 2 years ago

This is what the settings looks like now, keys are the same in MPT/MPR (with exceptions where MPT has more defined.). Keys are camelcase excepting the parameters which would be uninteligible imho. I tried to recover the text values' data types (float,number, string) in the text file (MPR/MPS) using the binary params, more or less.

    { //MPR parser settings 
      technique: 'CP',
      comments: '',
      activeMaterialMass: 0.0010000000474974513,
      atX: 0,
      molecularWeight: 0.0010000000474974513,// --> rare but seems to be consistent
      atomicWeight: 0.0010000000474974513,// --> rare but seems to be consistent
      acquisitionStart: 0,
      eTransferred: 1,// --> this key is still named different I think
      electrodeMaterial: '',
      electrolyte: '',
      electrodeSurfaceArea: 0.0010000000474974513,
      referenceElectrode: 'SCE Saturated Calomel Electrode',
      characteristicMass: 0.0010000000474974513,
      batteryCapacity: 3.615350037958028e-43,
      batteryCapacityUnit: 0,
      params: {
        Is: -100,
        Is_unit: 'mA',
        Is_vs: 2,
        ts: 120,
        EM: NaN,
        dQM: 3.3329999446868896,
        dQM_unit: 1,
        record: 1,
        dEs: 0,
        dts: 1,
        E_range_min: -10,
        E_range_max: 10,
        I_range: '1 A',
        bandwidth: 8,
        goto_Ns: 0,
        nc_cycles: 0
      }
    } 
{//MPT settings
      technique: 'CP',
      params: {
        Is: { value: -100 }, // Shall we keep as object or just Is: -100 ?
        Is_unit: { value: 'mA' },
        Is_vs: { value: '<None>' },
        ts: { units: 'h:m:s', value: '0:02:0.0000' }, // but this needs to be object, I tried to keep same shape to each key
        EM: { units: 'V', value: 'pass' },
        dQM: { value: 3.333 },
        dQM_unit: { value: 'mA.h' },
        record: { value: '<Ewe>' },
        dEs: { value: 0 },
        dts: { value: 1 },
        E_range_min: { units: 'V', value: -10 },
        E_range_max: { units: 'V', value: 10 },
        I_range: { value: '1 A' },
        bandwidth: { value: 8 },
        goto_Ns: { value: 0 },
        nc_cycles: { value: 0 }
      },
      flags: [ 'Record Ece', 'Text export' ],
      user: '',
      electrodeConnection: 'standard',
      'ewe,iFiltering': { value: 50, unit: 'kHz' },
      safetyLimits: '',
      channel: 'Grounded',
      acquisitionStartedOn: '03/02/2021 16:17:59',
      techniqueStartedOn: '03/02/2021 16:23:27',
      electrodeMaterial: '',
      initialState: '',
      electrolyte: '',
      comments: '',
      cable: 'standard',
      referenceElectrode: 'SCE Saturated Calomel Electrode (0.241 V)',
      electrodeSurfaceArea: { value: 0.001, unit: 'cm�' },
      characteristicMass: { value: 0.001, unit: 'g' },
      equivalentWeight: { value: 0, unit: 'g/eq.' },
      density: { value: 0, unit: 'g/cm3' },
      mode: 'Standard',
      cycleDefinition: 'Charge/Discharge alternance'
    }
{ //another parser settings and params
  "settings": {
    "technique": "CP",
    "comments": "",
    "active_material_mass": 0.0010000000474974513,
    "at_x": 0.0,
    "molecular_weight": 0.0010000000474974513,
    "atomic_weight": 0.0010000000474974513,
    "acquisition_start": 0.0,
    "e_transferred": 1,
    "electrode_material": "",
    "electrolyte": "",
    "electrode_area": 0.0010000000474974513,
    "reference_electrode": "SCE Saturated Calomel Electrode",
    "characteristic_mass": 0.0010000000474974513,
    "battery_capacity": 0.0,
    "battery_capacity_unit": 0
  },
  "params": [
    {
      "Is": -100.0,
      "Is_unit": "mA",
      "Is_vs": 2,
      "ts": 120.0,
      "EM": "nan",
      "dQM": 3.3329999446868896,
      "dQM_unit": 1,
      "record": 1,
      "dEs": 0.0,
      "dts": 1.0,
      "E_range_min": -10.0,
      "E_range_max": 10.0,
      "I_range": "1 A",
      "bandwidth": 8,
      "goto_Ns": 0,
      "nc_cycles": 0
    }
}

The logs, which may be less important:

    { //MPR notice the number 0 and then 1 in MPT, dunno
      runOnChannel: { number: 0, serial: 5304 },
      eweControlRange: { min: -10, max: 10 },
      oleTimestamp: 44257.67915509259,
      filename: 'C:\\EmpaDaten\\Alessandro\\2021_03_02_spAg_Porex_01\\Batch_1_1_20210210_CP_100mA_-3.33V_02_CP_C01.mpr',
      host: '10.1.1.100',
      address: 'USB',
      ecLabVersion: '11.33',
      serverVersion: '11.32',
      interpreterVersion: '',
      deviceSerial: '0200',
      averagingPoints: 0
    } {// MPT parser
      flags: [],
      runOnChannel: { number: 1, serial: 5304 },
      eweCtrlRange: { min: -10, minUnit: 'V', max: 10, maxUnit: 'V' },
      savedOn: '',
      device: 'SP-240 (SN 0200)', // --> this could be `device: { name, serial }`
      address: 'USB',
      ecLabVersion: 'v11.33',
      serverVersion: 'v11.32',
      interpreterVersion: 'v11.33'
    }

  "log": {// another parser
    "channel_number": 0,
    "channel_sn": 5304,
    "Ewe_ctrl_min": -10.0,
    "Ewe_ctrl_max": 10.0,
    "ole_timestamp": 44257.67915509259,
    "filename": "C:\\EmpaDaten\\Alessandro\\2021_03_02_spAg_Porex_01\\Batch_1_1_20210210_CP_100mA_-3.33V_02_CP_C01.mpr",
    "host": "10.1.1.100",
    "address": "USB",
    "ec_lab_version": "11.33",
    "server_version": "11.32",
    "interpreter_version": "11.33",
    "device_sn": "0200",
    "averaging_points": 0
  }

This is more or less the output (didn't include the data bc it is not compatible yet). But is this more or less what you expected @lpatiny ?