Skip to content

Create plots with original axis units #25

Description

@DunklesArchipel

The plots on the website should be shown with the original axis units. That information is located in the JSON file in figure description. The CSV is in SI units.

To convert units we can use astropy. For example

from astropy import units as u
q = 1 * u.V / u.cm**2
q.to(u.MV / u.m**2)

We can determine the conversion factor from SI units to the original figure unit.
With the factor, we need to multiply the current axis in the df.
Note that the current can be current density or current, hence A or A / cm2.

import pandas as pd
import json

df = pd.read_csv('./website/literature/alves_2011_electrochemistry_6010/alves_2011_electrochemistry_6010_p2_2a_solid.csv')

with open('./website/literature/alves_2011_electrochemistry_6010/alves_2011_electrochemistry_6010_p2_2a_solid.json') as f:
    metadata = json.load(f)

current = u.Unit(metadata['figure description']['current']['unit'])
    
if 'j' in df.columns:
    factor = (u.A / u.m**2).to(current)
if 'I' in df.columns:
    factor = (u.A).to(current)
    
factor

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions