use of org.tensorics.core.quantity.QuantifiedValue in project tensorics-core by tensorics.
the class FakeMeteoDataImporter method importFromPastCorrupted.
public static Tensor<QuantifiedValue<Double>> importFromPastCorrupted() {
Set<Class<?>> dimensions = ImmutableSet.of(Time.class, Longitude.class, Latitude.class);
Builder<QuantifiedValue<Double>> tensorBuilder = ImmutableTensor.<QuantifiedValue<Double>>builder(dimensions);
Random rand = new Random();
for (int x = 0; x < 10; x++) {
for (int y = 0; y < 10; y++) {
for (int t = 0; t < 10; t++) {
if (y != 5) {
QuantifiedValue<Double> entryValue = ImmutableQuantifiedValue.<Double>of(rand.nextDouble(), JScienceUnit.of(SI.CELSIUS));
tensorBuilder.put(Position.of(new Time(t), new Longitude(x), new Latitude(y)), entryValue);
}
}
}
}
return tensorBuilder.build();
}
use of org.tensorics.core.quantity.QuantifiedValue in project tensorics-core by tensorics.
the class MeteoDataImporterTest method testAverageTemperatureByTime.
@Test
public void testAverageTemperatureByTime() {
Tensor<QuantifiedValue<Double>> importFromPast = FakeMeteoDataImporter.importFromPast();
Tensor<Double> byAveragingIn = from(QuantityTensors.valuesOf(importFromPast)).reduce(Time.class).byAveragingIn(Structures.doubles());
System.out.println("Averaged over time " + byAveragingIn);
Tensor<Double> tempAtTime4 = from(QuantityTensors.valuesOf(importFromPast)).extract(new Time(4));
System.out.println("Sliced on time = 4 " + tempAtTime4);
}
use of org.tensorics.core.quantity.QuantifiedValue in project tensorics-core by tensorics.
the class WeatherHistoryInEurope method calculate.
// tag::import[]
/*
* calculate an average monthly temperature at the ROME Latitude like cities
*/
@SuppressWarnings("unused")
public void calculate() {
Tensor<QuantifiedValue<Double>> importedData = importDataForCities();
Latitude romeLatitude = EuropeanCapital.ROMA.getLatitude();
Tensor<QuantifiedValue<Double>> sliceAtTropicCancerAndRome = from(importedData).extract(romeLatitude);
Temperature temperature = new Temperature(importedData);
Tensor<QuantifiedValue<Double>> elementTimes = calculateQ(importedData).elementTimes(importedData);
Temperature elementTimes2 = calculateQ(temperature).elementTimes(temperature);
/* dimension will be reduced to only Longitude and Time */
sliceAtTropicCancerAndRome.shape().dimensionSet();
//
// from(sliceAtTropicCancerAndRome).reduce(Time.class).byAveragingIn(field)
TensoricSupport<Double> fullTensoricSupport = Tensorics.using(Structures.doubles());
}
use of org.tensorics.core.quantity.QuantifiedValue in project tensorics-core by tensorics.
the class TensorCalculationsTest method profileQuantifiedRepetitiveTensor.
@Ignore
@Test
public void profileQuantifiedRepetitiveTensor() {
final Unit unit = JScienceUnit.of(SI.METER);
CoordinateRange range = CoordinateRange.fromSize(TensorSize.ofXYZ(100, 1000, 1));
List<ProfileResult> results = profileTensorCreationNTimes(10, range, new ValueFactory<QuantifiedValue<Double>>() {
@Override
public QuantifiedValue<Double> create(int x, int y, int z) {
return Tensorics.quantityOf(valueForBig(x, y, z, 2.0), unit).withError(0.0);
}
});
printProfileResult(results);
}
use of org.tensorics.core.quantity.QuantifiedValue in project tensorics-core by tensorics.
the class FakeMeteoDataImporter method importFromPast.
public static Tensor<QuantifiedValue<Double>> importFromPast() {
Set<Class<?>> dimensions = ImmutableSet.of(Time.class, Longitude.class, Latitude.class);
Builder<QuantifiedValue<Double>> tensorBuilder = ImmutableTensor.<QuantifiedValue<Double>>builder(dimensions);
Random rand = new Random();
for (int x = 0; x < 10; x++) {
for (int y = 0; y < 10; y++) {
for (int t = 0; t < 10; t++) {
QuantifiedValue<Double> entryValue = ImmutableQuantifiedValue.<Double>of(rand.nextDouble(), JScienceUnit.of(SI.CELSIUS));
tensorBuilder.put(Position.of(new Time(t), new Longitude(x), new Latitude(y)), entryValue);
}
}
}
return tensorBuilder.build();
}
Aggregations