Skip to content

Added units for Astronomy. #680

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

Merged
merged 13 commits into from
Jul 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Common/UnitDefinitions/Length.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,50 @@
"Abbreviations": [ "h", "hh" ]
}
]
},
{
"SingularName": "AstronomicalUnit",
"PluralName": "AstronomicalUnits",
"FromUnitToBaseFunc": "x * 1.4959787070e11",
"FromBaseToUnitFunc": "x / 1.4959787070e11",
"XmlDocSummary": "One Astronomical Unit is the distance from the solar system Star, the sun, to planet Earth.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Astronomical_unit",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "au", "ua" ]
}
]
},
{
"SingularName": "Parsec",
"PluralName": "Parsecs",
"FromUnitToBaseFunc": "x * 3.08567758128e16",
"FromBaseToUnitFunc": "x / 3.08567758128e16",
"XmlDocSummary": "A parsec is defined as the distance at which one astronomical unit (AU) subtends an angle of one arcsecond.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Parsec",
"Prefixes": [ "Kilo", "Mega" ],
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "pc" ]
}
]
},
{
"SingularName": "LightYear",
"PluralName": "LightYears",
"FromUnitToBaseFunc": "x * 9.46073047258e15",
"FromBaseToUnitFunc": "x / 9.46073047258e15",
"XmlDocSummary": "A Light Year (ly) is the distance that light travel during an Earth year, ie 365 days.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Light-year",
"Prefixes": [ "Kilo", "Mega" ],
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "ly" ]
}
]
}
]
}
40 changes: 40 additions & 0 deletions Common/UnitDefinitions/Luminosity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"Name": "Luminosity",
"BaseUnit": "Watt",
"BaseType": "double",
"XmlDoc": "Luminosity is an absolute measure of radiated electromagnetic power (light), the radiant power emitted by a light-emitting object.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminosity",
"BaseDimensions": {
"L": 2,
"M": 1,
"T": -3
},
"Units": [
{
"SingularName": "Watt",
"PluralName": "Watts",
"FromUnitToBaseFunc": "x",
"FromBaseToUnitFunc": "x",
"Prefixes": [ "Femto", "Pico", "Nano", "Micro", "Milli", "Deci", "Deca", "Kilo", "Mega", "Giga", "Tera", "Peta" ],
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "W" ]
}
]
},
{
"SingularName": "SolarLuminosity",
"PluralName": "SolarLuminosities",
"FromUnitToBaseFunc": "x * 3.846e26",
"FromBaseToUnitFunc": "x / 3.846e26",
"XmlDocRemarks": "https://www.britannica.com/science/luminosity",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "L⊙" ]
}
]
}
]
}
34 changes: 34 additions & 0 deletions Common/UnitDefinitions/Mass.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,40 @@
"Abbreviations": [ "gr" ]
}
]
},
{
"SingularName": "SolarMass",
"PluralName": "SolarMasses",
"BaseUnits": {
"M": "SolarMass"
},
"FromUnitToBaseFunc": "x * 1.98947e30",
"FromBaseToUnitFunc": "x / 1.98947e30",
"XmlDocSummary": "Solar mass is a ratio unit to the mass of the solar system star, the sun.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Solar_mass",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "M⊙" ]
}
]
},
{
"SingularName": "EarthMass",
"PluralName": "EarthMasses",
"BaseUnits": {
"M": "EarthMass"
},
"FromUnitToBaseFunc": "x * 5.9722E+24",
"FromBaseToUnitFunc": "x / 5.9722E+24",
"XmlDocSummary": "Earth mass is a ratio unit to the mass of planet Earth.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Earth_mass",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "em" ]
}
]
}
]
}
14 changes: 14 additions & 0 deletions UnitsNet.Tests/CustomCode/LengthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ public class LengthTests : LengthTestsBase

protected override double HandsInOneMeter => 9.8425196850393701;

protected override double AstronomicalUnitsInOneMeter => 6.6845871222684500000000000E-12;

protected override double KilolightYearsInOneMeter => 1.0570008340247000000000000E-19;

protected override double KiloparsecsInOneMeter => 3.2407790389471100000000000E-20;

protected override double LightYearsInOneMeter => 1.0570008340247000000000000E-16;

protected override double MegalightYearsInOneMeter => 1.0570008340247000000000000E-22;

protected override double MegaparsecsInOneMeter => 3.2407790389471100000000000E-23;

protected override double ParsecsInOneMeter => 3.2407790389471100000000000E-17;

[ Fact]
public void AreaTimesLengthEqualsVolume()
{
Expand Down
56 changes: 56 additions & 0 deletions UnitsNet.Tests/CustomCode/LuminosityTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by \generate-code.bat.
//
// Changes to this file will be lost when the code is regenerated.
// The build server regenerates the code before each build and a pre-build
// step will regenerate the code on each local build.
//
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities.
//
// </auto-generated>
//------------------------------------------------------------------------------

// Licensed under MIT No Attribution, see LICENSE file at the root.
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet.

using System;

namespace UnitsNet.Tests.CustomCode
{
public class LuminosityTests : LuminosityTestsBase
{
// Override properties in base class here
protected override double FemtowattsInOneWatt => 1e15;

protected override double PicowattsInOneWatt => 1e12;

protected override double NanowattsInOneWatt => 1e9;

protected override double MicrowattsInOneWatt => 1e6;

protected override double MilliwattsInOneWatt => 1e3;

protected override double DeciwattsInOneWatt => 1e1;

protected override double WattsInOneWatt => 1;

protected override double DecawattsInOneWatt => 1e-1;

protected override double KilowattsInOneWatt => 1e-3;

protected override double MegawattsInOneWatt => 1e-6;

protected override double GigawattsInOneWatt => 1e-9;

protected override double TerawattsInOneWatt => 1e-12;

protected override double PetawattsInOneWatt => 1e-15;

protected override double SolarLuminositiesInOneWatt => 2.6001040041601700000000000E-27;

}
}
6 changes: 6 additions & 0 deletions UnitsNet.Tests/CustomCode/MassTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public class MassTests : MassTestsBase

protected override double ShortHundredweightInOneKilogram => 0.022046226218487758;

protected override double EarthMassesInOneKilogram => 1.6744248350691500000000000E-25;

protected override double SolarMassesInOneKilogram => 5.0264643347223100000000000E-31;

//protected override double SolarMassesTolerance => 0.1;

[Fact]
public void AccelerationTimesMassEqualsForce()
{
Expand Down
Loading