Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

f_calculator #9

Open
JungHulk opened this issue Jan 31, 2023 · 0 comments
Open

f_calculator #9

JungHulk opened this issue Jan 31, 2023 · 0 comments

Comments

@JungHulk
Copy link
Owner

JungHulk commented Jan 31, 2023

# -*- coding: utf-8 -*-
"""
Created on Tue Jan 31 18:05:11 2023

@author: seungj.jung
"""

import os
import pandas as pd
import pickle

unitconv_length = pd.read_pickle('Unitconv_length.p')
unitconv_area = pd.read_pickle('Unitconv_area.p')
unitconv_volume = pd.read_pickle('Unitconv_volume.p')
unitconv_pressure = pd.read_pickle('Unitconv_pressure.p')

class unitconv:

    def __init__(self,selection, fromunit, tounit, value):
        self.type  = selection # length, area, volume
        self.funit = fromunit  # 기존 단위
        self.tunit = tounit    # 변경하고자 하는 단위
        self.value = value     # 값
        
    def cal(self):
        if self.type == "length":
            factor = unitconv_length.loc[self.funit, self.tunit]
            sol = factor * self.value
            
        elif self.type =="area":
            factor = unitconv_area.loc[self.funit, self.tunit]
            sol = factor * self.value
            
        elif self.type =="volume":
            factor = unitconv_volume.loc[self.funit, self.tunit]
            sol = factor * self.value
            
        elif self.type =="pressure":
            factor = unitconv_pressure.loc[self.funit, self.tunit]
            sol = factor * self.value
        
        return sol

      
## a = unitconv("length","mm", "ft", 50)
## b = a.cal()

## a = unitconv("length","mm", "ft", 50).cal()


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant