Create or refresh data files (if using Physique for the first time, do this first!) by running this script in the root directory of the project (i.e. ./Physique/):
python3 ./Scripts/Refresh.py
For instance, you would leave this current directory, change to the directory above (or wherever it really is) for the root directory of the project, and type the above command in the command line.
Alternatively, do it in Python here:
In [1]:
import os
print(os.getcwd())
In [2]:
os.chdir(os.getcwd() + "/Physique/") # change current working directory
In [3]:
print(os.getcwd())
In [4]:
%run -i ./Scripts/Refresh.py # this is the main, important, command to run
In [5]:
import Physique
In [6]:
import sys
In [7]:
sys.executable # Check which Python you are running in case you have ImportError's
Out[7]:
In [8]:
print(dir(Physique))
In [8]:
from Physique import FundamentalPhysicalConstants as FPC
In [11]:
print(FPC.columns)
In [12]:
print(FPC)
Find a Fundamental Constant you are interested in using the usual panda modules
In [13]:
g_0pd = FPC[FPC["Quantity"].str.contains("gravity") ]
# standard acceleration of gravity as a panda DataFrame
print(g_0pd)
In [18]:
g_0 = g_0pd["Value"].values[0]
print(type(g_0))
print(g_0)
In [21]:
# access the values you're interested in
print(g_0pd.Quantity)
print(g_0pd.Value.get_values()[0])
print(g_0pd.Unit.get_values()[0])
In [22]:
# you can also grab just the 1 entry from this DataFrame using the .loc module
FPC[FPC["Quantity"].str.contains("Boltzmann")].loc[49,:]
Out[22]:
In [23]:
g_0pd.loc[303,:]
Out[23]:
This is the pandas DataFrame containing all the NIST Official Conversions to SI.
In [24]:
from Physique import Conversions
In [25]:
print(Conversions.columns)
From the list of columns, search for the quantity you desired by trying out different search terms: e.g. I'm reading Huzel and Huang's Modern Engineering for Design of Liquid-Propellant Rocket Engines and I want to know how to convert from
We can try to look up the U.S. or Imperial units from the Toconvertfrom column.
In [27]:
Conversions[Conversions['Toconvertfrom'].str.contains("pound-force ")]
Out[27]:
Or we can look up the SI unit we want to convert to.
In [29]:
Conversions[Conversions['to'].str.contains("newton ")]
Out[29]:
Look at what you want and see the index; it happens to be 340 in this example.
In [30]:
lbf2N = Conversions.loc[340,:];
print(lbf2N)
Then the attributes can accessed by the column names.
In [31]:
print(lbf2N.Toconvertfrom)
print(lbf2N.to)
print(lbf2N.Multiplyby)
So for example, the reusable SSME delivers a vacuum thrust of 470000 lb or
In [32]:
print(470000 * lbf2N.Multiplyby, lbf2N.to)
To obtain the conversion for pressure in psia, which we search for with "psi"
In [33]:
Conversions[Conversions['Toconvertfrom'].str.match("psi")]
Out[33]:
So for a chamber pressure of 3028 psia for the SSME,
In [35]:
psi2Pa = Conversions.loc[372,:]
print(3028 * psi2Pa.Multiplyby, psi2Pa.to)
Also, get the conversion for atmospheres (atm):
In [36]:
Conversions[Conversions['Toconvertfrom'].str.match("atm")]
Out[36]:
In [37]:
atm2Pa = Conversions.loc[15,:]
In [38]:
print(3028 * psi2Pa.Multiplyby / atm2Pa.Multiplyby, atm2Pa.Toconvertfrom)
In [ ]: