Skip to main content

Perform required calculations on sexagesimal coordinates

Project description

Sexagesimal Calculator

The Sexagesimal Calculator performs all the required calculations on sexagesimal coordinates. During the calculations, all the intermediate steps are performed in sexagesimal number system and no sort of conversion to decimal number system takes place in the background.

This was developed for the summer project for the HoMI (History of Mathematics in India) initiative at Indian Institute of Technology, Gandhinagar. For more information about this project see the Indian Numerical Decoding and Encoding Applications page.

Installation

You can install the Real Python Feed Reader from PyPI:

python -m pip install sexagesimal-calculator

The reader is supported on Python 3.7 and above.

How to use

>>> from sexagesimal_calculator.sexagesimal import Sexagesimal
>>> A = Sexagesimal(289)
>>> A
04,49;00
>>> A = Sexagesimal('289')
>>> A
04,49;00
>>> B = Sexagesimal('4;34,54')
>>> B
04;34,54
>>> C = Sexagesimal('5;456')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\hrush\OneDrive - iitgn.ac.in\Desktop\sexagesimal-calculator\sexagesimal_calculator\sexagesimal.py", line 51, in __init__
    raise Exception("Fractional Part has 60+ entry")
Exception: Fractional Part has 60+ entry

1. Decimal to Sexagesimal Converter (Input should be decimal number.)

  • Allowed inputs - 1, 0.23, .23, 1.0
  • Use Sexagesimal.Decimal2Sexagesimal(Input, Accuracy=20)
  • Accuracy (optional) :
    • The number of digits to consider after the decimal point.
    • Default value is 20 (digits after decimal point).
    • Example : If input is 1.23456 and accuracy is 2, then the program will consider only 1.23 for conversion.
>>> A = Sexagesimal(1.23456)
01;14,04,24,57,36
>>> Sexagesimal.Decimal2Sexagesimal(1.23456, 2)
01;13,48
>>> Sexagesimal.Decimal2Sexagesimal(1.23)
01;13,48

2. Sexagesimal to Decimal Converter:

  • Input should be a sexagesimal number.
  • ; should be used to separat the intergal part
  • , should be used to separate the fractional apart.
  • Use Sexagesimal.Sexagesimal2Decimal(Input, precision=20)
  • Example : 12;01,45,12
  • Precision (optional) :
    • Number of fractional places to consider in the final result.
    • Examples:
      • 21;19,53,47,43,29 ---> 21.33160983667695473251 (20 decimal places).
      • But if Precision value is 30, then the result will be 21.331609836676954732510288065844
    • By default, the program will give result till 20 decimal places.
    • This option is helpful if the given sexagesimal number contains a non-regular number in the fractional part.
>>> A = Sexagesimal('21;19,53,47,43,29')
>>> Sexagesimal.Sexagesimal2Decimal(A)                  
'21.33160983667695473251'
>>> Sexagesimal.Sexagesimal2Decimal(A, 30) 
'21.331609836676954732510288065844'
>>> Sexagesimal.Sexagesimal2Decimal(A, 10) 
'21.3316098367'
>>> Sexagesimal.Sexagesimal2Decimal(A, 50) 
'21.33160983667695473251028806584362139917695473251029'

3. Addition and Subtraction:

  • Input can be in the decimal form, sexagesimal form or mixed.
  • But the answer will always be in the sexagesimal form
>>> Sexagesimal(1.23) + Sexagesimal(4.32) - Sexagesimal(5.32)
00;13,48
>>> Sexagesimal('4;2,45') + Sexagesimal('6;12,1') - Sexagesimal('1,45;12,56,38')
-01,34;58,10,38
>>> Sexagesimal(1.23) + Sexagesimal(4.32) - Sexagesimal('1,45;12,56,38')
-01,39;39,56,38

4. Multiplication:

  • Input can be in the decimal form, sexagesimal form or mixed.
  • But the answer will always be in the sexagesimal form
>>> Sexagesimal(1.23) + Sexagesimal(4.32) - Sexagesimal('1,45;12,56,38')
-01,39;39,56,38
>>> Sexagesimal(1.23) * Sexagesimal(- 5.32)
-06;32,36,57,36
>>> Sexagesimal('-4;2,45') * Sexagesimal('-6;12,1')
25;05,07,02,45
>>> Sexagesimal(-4.32) * Sexagesimal('1,45;12,56,38')
-07,34;31,55,03,21,36
  • Verbose (Optional):

    • When selected the program will print every step involved in the calculation.
    • This can be used to check the steps and confirm the correctness.
    • It also shows that all the intermediate calculations are done in sexagesimal number system and there is no back and forth from the decimal system.
    • Use Sexagesimal.Multiplication(A, B, verbose=True)
    >>> A = Sexagesimal(1.332)
    >>> B = Sexagesimal(3.53)
    >>> res, details = Sexagesimal.Multiplication(A, B, True)
    >>> res
    04;42,07,03,21,36
    >>> print(details)
    

5. Division:

  • The inputs (Dividend and Divisor) can be decimal, sexagesimal or mixed.
  • But the answer will always be in the sexagesimal form.
>>> Sexagesimal(3.24) / Sexagesimal(6.12)
00;31,45,52,56,28,14,07,03,31,45,52,56,28,14,07,03,31,45,52,56
>>> Sexagesimal('03;14,24') / Sexagesimal('06;07,12')
00;31,45,52,56,28,14,07,03,31,45,52,56,28,14,07,03,31,45,52,56
>>> Sexagesimal(3.24) / Sexagesimal('6;04')
00;32,02,38,14,30,19,46,48,47,28,21,05,56,02,38,14,30,19,46,49
  • Precision :
    • By default, the program prints final answer upto 20 fractional places.
    • This option could be used to increase or decrease the number of fractional places to be displayed in the final answer.
    >>> A = Sexagesimal(3.24)
    >>> B = Sexagesimal('6;04')
    >>> Sexagesimal.Division(A, B)
    00;32,02,38,14,30,19,46,48,47,28,21,05,56,02,38,14,30,19,46,49
    >>> Sexagesimal.Division(A, B, precision=10)
    00;32,02,38,14,30,19,46,48,47,28
    >>> Sexagesimal.Division(A, B, precision=30)
    00;32,02,38,14,30,19,46,48,47,28,21,05,56,02,38,14,30,19,46,48,47,28,21,05,56,02,38,14,30,20
    
  • Verbose :
    • When selected the program will print every step involved in the calculation.
    • This can be used to check the steps and confirm the correctness.
    • Use Sexagesimal.Division(A, B, verbose=True)
    >>> A = Sexagesimal(3.24)
    >>> B = Sexagesimal('6;04')
    >>> res, details = Sexagesimal.Division(A, B, verbose=True) 
    >>> res
    00;32,02,38,14,30,19,46,48,47,28,21,05,56,02,38,14,30,19,46,49
    >>> print(details)
    

6. Increment Table Generator:

  • Used to create the addition and subtraction tables.
  • The Initial value and the Increment value can be in decimal, sexagesimal or mixed form.
  • The Row and Mod has to be a positive integer.
  • If mod is less than 2, then the integral part of values will be a decimal and will not be moded.
  • Use IncrementTableGenerator(Inc_Initial, Inc_Increment, Inc_Rows=10, Inc_Mod=60)
>>> Sexagesimal.IncrementTableGenerator('10;10', '20;10', 15, 60)
['10;10', '30;20', '50;30', '10;40', '30;50', '51;00', '11;10', '31;20', '51;30', '11;40', '31;50', '52;00', '12;10', '32;20', '52;30', '12;40']
>>> Sexagesimal.IncrementTableGenerator('10;10', '20;10', 15, 30)
['10;10', '00;20', '20;30', '10;40', '00;50', '21;00', '11;10', '01;20', '21;30', '11;40', '01;50', '22;00', '12;10', '02;20', '22;30', '12;40']
>>> Sexagesimal.IncrementTableGenerator('10;10', '20;10', 15, 90)
['10;10', '30;20', '50;30', '70;40', '0;50', '21;00', '41;10', '61;20', '81;30', '11;40', '31;50', '52;00', '72;10', '2;20', '22;30', '42;40']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sexagesimal-calculator-1.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

sexagesimal_calculator-1.1.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file sexagesimal-calculator-1.1.0.tar.gz.

File metadata

  • Download URL: sexagesimal-calculator-1.1.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for sexagesimal-calculator-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e0b188d9040739bce9827acb855c96e9f3a4e03d090e86345dc0774488acfe40
MD5 c7186ed27f19605aae21ea18ead5d818
BLAKE2b-256 8e132d8b789a866bcb9f57b856531bbe0e039d7aaef0e8c6be8d4471311c5dcb

See more details on using hashes here.

File details

Details for the file sexagesimal_calculator-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: sexagesimal_calculator-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for sexagesimal_calculator-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df17387f2414f566c581e798b43e8f852042db9be018e374f65c67aa7a96cd7b
MD5 1a4d7201dbe84d7069cd61e35ab9c690
BLAKE2b-256 880088a94ae723593df74b5fbcb3c1ff916b1dafd93a1a06221d58fa1e45df60

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page