Class: HumidityRatio

PD.Units. HumidityRatio

Provides tools to convert between different humidity ratio units.

Use static methods for arbitrary conversions and instance methods when converting to and/or from a specific unit multiple times. The available humidity ratio unit types are: PD.Units.KILOGRAMS_PER_KILOGRAM, PD.Units.GRAMS_PER_KILOGRAM, PD.Units.POUNDS_PER_POUND and PD.Units.GRAINS_PER_POUND.


new HumidityRatio( [units])

Creates a new humidity ratio converter.

Parameters:
Name Type Argument Description
units number <optional>

The units type identifier, defaults to PD.Units.KILOGRAMS_PER_KILOGRAM.

Example
/// Create new object to convert to/from g/kg.
const g_kg = new PD.Units.HumidityRatio(PD.Units.GRAMS_PER_KILOGRAM);

/// Convert to other humidity ratio units.
const kg_kg = g_kg.toKilogramsPerKilogram(24.0);
const gr_lb = g_kg.toGrainsPerPound(25.4);
console.log(kg_kg, gr_lb); // > 0.024, 177.8

/// Assign a new value using lb/lb.
const v1 = g_kg.fromPoundsPerPound(0.0021);
console.log(v1); // > 2.1

/// Using static methods.
const v2 = PD.Units.HumidityRatio.convertGrainsPerPoundToGramsPerKilogram(20.0);
const units_abbrev = PD.Units.HumidityRatio.getAbbrev(PD.Units.GRAMS_PER_KILOGRAM);
const output = v2.toFixed(3) + units_abbrev; // '2.857g/kg'

Members


:number

units

The numeric identifier defining the type of stored units.

The value of this property should equate to PD.Units.KILOGRAMS_PER_KILOGRAM, PD.Units.GRAMS_PER_KILOGRAM, PD.Units.POUNDS_PER_POUND or PD.Units.GRAINS_PER_POUND. Any other value is assumed to be kilograms of water per kilogram of dry air.

Type
  • number

Methods


fromGrainsPerPound(gr_lb)

Converts from grains water per pound of dry air (gr/lb) to the current units.

Parameters:
Name Type Description
gr_lb number

The value to convert in grains water per pound of dry air (gr/lb).

Returns:

Returns the value converted to the current units.

Type
number

fromGramsPerKilogram(g_kg)

Converts from grams water per kilogram of dry air (g/kg) to the current units.

Parameters:
Name Type Description
g_kg number

The value to convert in grams water per kilogram of dry air (g/kg).

Returns:

Returns the value converted to the current units.

Type
number

fromKilogramsPerKilogram(kg_kg)

Converts from kilograms water per kilogram of dry air (kg/kg) to the current units.

Parameters:
Name Type Description
kg_kg number

The value to convert in kilograms water per kilogram of dry air (kg/kg).

Returns:

Returns the value converted to the current units.

Type
number

fromPoundsPerPound(lb_lb)

Converts from pounds water per pound of dry air (lb/lb) to the current units.

Parameters:
Name Type Description
lb_lb number

The value to convert in pounds water per pound of dry air (lb/lb).

Returns:

Returns the value converted to the current units.

Type
number

getAbbrev()

Retrieve the abbreviation of the stored units.

Depending on the current units, this method returns one of the following string values: 'kg/kg', 'g/kg', 'lb/lb' or 'gr/lb';

Returns:

Returns the abbreviation of the current units.

Type
string

getName()

Retrieve the full name of the stored units.

Depending on the current units, this method returns one of the following string values: 'kilogramsPerKilogram', 'gramsPerKilogram', 'PoundsPerPound' or 'grainsPerPound'.

Returns:

Returns the full name of the current units.

Type
string

getUnitsId()

Retrieves the currently units identifier as a numeric value.

Returns:

Returns the current units identifier.

Type
number

set(units)

Sets the current humidity ratio unit and updates conversions.

Parameters:
Name Type Description
units number

The new units identifier (PD.Units.KILOGRAMS_PER_KILOGRAM | GRAMS_PER_KILOGRAM | POUNDS_PER_POUND | GRAINS_PER_POUND).

Returns:

Returns this HumidityRatio object to support method chaining.

Type
object

toGrainsPerPound(value)

Converts the given value to grains water per pound of dry air (gr/lb).

Parameters:
Name Type Description
value number

The value to convert, must be in stored units.

Returns:

Returns the value converted to grains water per pound of dry air (gr/lb).

Type
number

toGramsPerKilogram(value)

Converts the given value to grams water per kilogram of dry air (g/kg).

Parameters:
Name Type Description
value number

The value to convert, must be in stored units.

Returns:

Returns the value converted to grams water per kilogram of dry air (g/kg).

Type
number

toKilogramsPerKilogram(value)

Converts the given value to kilograms water per kilogram of dry air (kg/kg).

Parameters:
Name Type Description
value number

The value to convert, must be in stored units.

Returns:

Returns the value converted to kilograms water per kilogram of dry air (kg/kg).

Type
number

toPoundsPerPound(value)

Converts the given value to pounds water per pound of dry air (lb/lb).

Parameters:
Name Type Description
value number

The value to convert, must be in stored units.

Returns:

Returns the value converted to pounds water per pound of dry air (lb/lb).

Type
number

convertGrainsPerPoundToGramsPerKilogram(lb_lb) <static>

Converts a humidity ratio value from pounds per pound to kilograms per kilogram.

Parameters:
Name Type Description
lb_lb number

A value in pounds per pound (lb/lb).

Returns:

Returns a value in grams per kilogram (g/kg).

Type
number

convertGrainsPerPoundToKilogramsPerKilogram(lb_lb) <static>

Converts a humidity ratio value from pounds per pound to kilograms per kilogram.

Parameters:
Name Type Description
lb_lb number

A value in pounds per pound (lb/lb).

Returns:

Returns a value in kilograms per kilogram (kg/kg).

Type
number

convertGrainsPerPoundToPoundsPerPound(lb_lb) <static>

Converts a humidity ratio value from grains per pound to pounds per pound.

Parameters:
Name Type Description
lb_lb number

A value in grains per pound (gr/lb).

Returns:

Returns a value in pounds per pound (lb/lb).

Type
number

convertGramsPerKilogramToGrainsPerPound(g_kg) <static>

Converts a humidity ratio value from grams per kilogram to grains per pound.

Parameters:
Name Type Description
g_kg number

A value in grams per kilogram (g/kg).

Returns:

Returns a value in grains per pound (gr/lb).

Type
number

convertGramsPerKilogramToKilogramsPerKilogram(g_kg) <static>

Converts a humidity ratio value from grams per kilogram to kilograms per kilogram.

Parameters:
Name Type Description
g_kg number

A value in grams per kilogram (g/kg).

Returns:

Returns a value in kilograms per kilogram (kg/kg).

Type
number

convertGramsPerKilogramToPoundsPerPound(g_kg) <static>

Converts a humidity ratio value from grams per kilogram to pounds per pound.

Parameters:
Name Type Description
g_kg number

A value in grams per kilogram (g/kg).

Returns:

Returns a value in pounds per pound (lb/lb).

Type
number

convertKilogramsPerKilogramToGrainsPerPound(kg_kg) <static>

Converts a humidity ratio value from kilograms per kilogram to grains per pound.

Parameters:
Name Type Description
kg_kg number

A value in kilograms per kilogram (kg/kg).

Returns:

Returns a value in grains per pound (gr/lb).

Type
number

convertKilogramsPerKilogramToGramsPerKilogram(kg_kg) <static>

Converts a humidity ratio value from kilograms per kilogram to grams per kilogram.

Parameters:
Name Type Description
kg_kg number

A value in kilograms per kilogram (kg/kg).

Returns:

Returns a value in grams per kilogram (g/kg).

Type
number

convertKilogramsPerKilogramToPoundsPerPound(kg_kg) <static>

Converts a humidity ratio value from kilograms per kilogram to pounds per pound.

Parameters:
Name Type Description
kg_kg number

A value in kilograms per kilogram (kg/kg).

Returns:

Returns a value in pounds per pound (lb/lb).

Type
number

convertPoundsPerPoundToGrainsPerPound(lb_lb) <static>

Converts a humidity ratio value from pounds per pound to grains per pound.

Parameters:
Name Type Description
lb_lb number

A value in pounds per pound (lb/lb).

Returns:

Returns a value in grains per pound (gr/lb).

Type
number

convertPoundsPerPoundToGramsPerKilogram(lb_lb) <static>

Converts a humidity ratio value from pounds per pound to grams per kilogram.

Parameters:
Name Type Description
lb_lb number

A value in pounds per pound (lb/lb).

Returns:

Returns a value in grams per kilogram (g/kg).

Type
number

convertPoundsPerPoundToKilogramsPerKilogram(lb_lb) <static>

Converts a humidity ratio value from pounds per pound to kilograms per kilogram.

Parameters:
Name Type Description
lb_lb number

A value in pounds per pound (lb/lb).

Returns:

Returns a value in kilograms per kilogram (kg/kg).

Type
number

getAbbrev(units) <static>

Retrieves the abbreviation of the given humidity ratio units.

Based on the given units, this method returns one of the following string values: 'kg/kg', 'g/kg', 'lb/lb' or 'gr/lb';

Parameters:
Name Type Description
units number

The numeric units identifier (PD.Units.KILOGRAMS_PER_KILOGRAM | GRAMS_PER_KILOGRAM | POUNDS_PER_POUND | GRAINS_PER_POUND).

Returns:

Returns the abbreviation of the given humidity ratio units.

Type
string

getName(units) <static>

Retrieves the name of the given humidity ratio units.

Based on the given units, this method returns one of the following string values: 'Kilograms per Kilogram', 'Grams per Kilogram', 'Pounds per Pound' or 'Grains per Pound'.

Parameters:
Name Type Description
units number

The numeric units identifier (PD.Units.KILOGRAMS_PER_KILOGRAM | GRAMS_PER_KILOGRAM | POUNDS_PER_POUND | GRAINS_PER_POUND).

Returns:

Returns the name of the given humidity ratio units.

Type
string

getUnitsFromAbbrev(abbrev) <static>

Retrieves the humidity ratio units identifier from the given abbreviation.

Interprets the abbreviations 'kg/kg', 'g/kg', 'lb/lb' or 'gr/lb' into the identifiers PD.Units.KILOGRAMS_PER_KILOGRAM | GRAMS_PER_KILOGRAM | POUNDS_PER_POUND | GRAINS_PER_POUND.

Parameters:
Name Type Description
abbrev string

The abbreviation of the given humidity ratio units.

Returns:

Returns the The numeric units identifier.

Type
number