当前位置: 首页>>代码示例>>Java>>正文


Java Interval.parse方法代码示例

本文整理汇总了Java中org.joda.time.Interval.parse方法的典型用法代码示例。如果您正苦于以下问题:Java Interval.parse方法的具体用法?Java Interval.parse怎么用?Java Interval.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.joda.time.Interval的用法示例。


在下文中一共展示了Interval.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromFile

import org.joda.time.Interval; //导入方法依赖的package包/类
public static ForecastErrorsAnalyzerParameters fromFile(Path file) throws FileNotFoundException, IOException {
    Properties properties = new Properties();
    try (InputStream input =  new FileInputStream(file.toFile())) {
        properties.load(input);
        return new ForecastErrorsAnalyzerParameters(
                Interval.parse(properties.getProperty("histoInterval")),
                properties.getProperty("feAnalysisId"),
                Double.parseDouble(properties.getProperty("ir")),
                Integer.parseInt(properties.getProperty("flagPQ")),
                Integer.parseInt(properties.getProperty("method")),
                Integer.parseInt(properties.getProperty("nClusters")),
                Double.parseDouble(properties.getProperty("percentileHistorical")),
                Integer.parseInt(properties.getProperty("modalityGaussian")),
                Integer.parseInt(properties.getProperty("outliers")),
                Integer.parseInt(properties.getProperty("conditionalSampling")),
                Integer.parseInt((properties.getProperty("nSamples") != null) ? properties.getProperty("nSamples") : "-1")
        );
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:20,代码来源:ForecastErrorsAnalyzerParameters.java

示例2: run

import org.joda.time.Interval; //导入方法依赖的package包/类
@Override
public void run(CommandLine line, ToolRunningContext context) throws Exception {
    Interval interval = Interval.parse(line.getOptionValue("interval"));
    HistoDbHorizon horizon = HistoDbHorizon.SN;
    if (line.hasOption("horizon")) {
        horizon = HistoDbHorizon.valueOf(line.getOptionValue("horizon"));
    }
    OfflineConfig config = OfflineConfig.load();
    try (HistoDbClient histoDbClient = config.getHistoDbClientFactoryClass().newInstance().create(true)) {
        Set<HistoDbAttributeId> attributeIds = new LinkedHashSet<>(histoDbClient.listAttributes());
        HistoDbStats stats = histoDbClient.queryStats(attributeIds, interval, horizon, true);
        for (HistoDbAttributeId attributeId : attributeIds) {
            context.getOutputStream().println(attributeId + ";" + (int) stats.getValue(HistoDbStatsType.COUNT, attributeId, -1));
        }
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:17,代码来源:HistoDbCountAttributesTool.java

示例3: load

import org.joda.time.Interval; //导入方法依赖的package包/类
public static ForecastErrorsAnalysisParameters load() {
    ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("fea-parameters");

    DateTime baseCaseDate = DateTime.parse(config.getStringProperty("baseCaseDate"));
    Interval histoInterval = Interval.parse(config.getStringProperty("histoInterval"));
    String feAnalysisId = config.getStringProperty("feAnalysisId");
    double ir = config.getDoubleProperty("ir");
    Integer flagPQ = config.getIntProperty("flagPQ");
    Integer method = config.getIntProperty("method");
    Integer nClusters = config.getIntProperty("nClusters");
    double percentileHistorical = config.getDoubleProperty("percentileHistorical");
    Integer modalityGaussian = config.getOptionalIntegerProperty("modalityGaussian").orElse(null);
    Integer outliers = config.getOptionalIntegerProperty("outliers").orElse(null);
    Integer conditionalSampling = config.getOptionalIntegerProperty("conditionalSampling").orElse(null);
    Integer nSamples = config.getIntProperty("nSamples");
    Set<Country> countries = config.getEnumSetProperty("countries", Country.class, DEFAULT_COUNTRIES);
    CaseType caseType = config.getEnumProperty("caseType", CaseType.class, DEFAULT_CASE_TYPE);

    return new ForecastErrorsAnalysisParameters(baseCaseDate, histoInterval, feAnalysisId, ir, flagPQ, method, nClusters, percentileHistorical,
                                                modalityGaussian, outliers, conditionalSampling, nSamples, countries, caseType);
}
 
开发者ID:itesla,项目名称:ipst,代码行数:22,代码来源:ForecastErrorsAnalysisParameters.java

示例4: testWrite

import org.joda.time.Interval; //导入方法依赖的package包/类
@Test
public void testWrite() throws Exception {        
    Network network = NetworkTest1Factory.create();
    Interval histoInterval = Interval.parse("2013-01-01T00:00:00+01:00/2013-01-31T23:59:00+01:00");

    UncertaintiesAnalyser uncertaintiesAnalyser = new UncertaintiesAnalyserTestImpl(network);
    Uncertainties uncertainties = uncertaintiesAnalyser.analyse(histoInterval).join();

    MemDataSource dataSource = new MemDataSource();

    StringToIntMapper<AmplSubset> mapper = new StringToIntMapper<>(AmplSubset.class);
    AmplUtil.fillMapper(mapper, network);

    new UncertaintiesAmplWriter(uncertainties, dataSource, mapper).write();

    String fileContent = String.join(System.lineSeparator(), 
                                     "#Reduction matrix",
                                     "#\"inj. type\" \"inj. num\" \"var. num\" \"coeff.\"",
                                     "L 1 1 1.00000",
                                     "G 1 2 1.00000");
    assertEquals(fileContent, new String(dataSource.getData(WCAConstants.REDUCTION_MATRIX_FILE_SUFFIX, WCAConstants.TXT_EXT), StandardCharsets.UTF_8).trim());

    fileContent = String.join(System.lineSeparator(),
                              "#Trust intervals",
                              "#\"var. num\" \"min\" \"max\"",
                              "1 -1.00000 1.00000",
                              "2 -90.0000 90.0000");
    assertEquals(fileContent, new String(dataSource.getData(WCAConstants.TRUST_INTERVAL_FILE_SUFFIX, WCAConstants.TXT_EXT), StandardCharsets.UTF_8).trim());

    fileContent = String.join(System.lineSeparator(),
                              "#Means",
                              "#\"inj. type\" \"inj. num\" \"mean\"",
                              "L 1 10.0000",
                              "G 1 900.000");
    assertEquals(fileContent, new String(dataSource.getData(WCAConstants.MEANS_FILE_SUFFIX, WCAConstants.TXT_EXT), StandardCharsets.UTF_8).trim());
}
 
开发者ID:itesla,项目名称:ipst,代码行数:37,代码来源:UncertaintiesAmplWriterTest.java

示例5: run

import org.joda.time.Interval; //导入方法依赖的package包/类
@Override
public void run(CommandLine line, ToolRunningContext context) throws Exception {
    Path caseFile = Paths.get(line.getOptionValue("case-file"));
    Interval interval = Interval.parse(line.getOptionValue("interval"));
    Path dictFile = null;
    if (line.hasOption("use-short-ids-dict")) {
        dictFile = Paths.get(line.getOptionValue("use-short-ids-dict"));
    }
    double correlationThreshold = Double.parseDouble(line.getOptionValue("correlation-threshold"));
    double probabilityThreshold = Double.parseDouble(line.getOptionValue("probability-threshold"));

    Network network = Importers.loadNetwork(caseFile);
    if (network == null) {
        throw new RuntimeException("Case '" + caseFile + "' not found");
    }
    network.getStateManager().allowStateMultiThreadAccess(true);

    OfflineConfig config = OfflineConfig.load();
    try (TopologyMiner topologyMiner = config.getTopologyMinerFactoryClass().newInstance().create()) {
        Path topoCacheDir = TopologyContext.createTopoCacheDir(network, interval, correlationThreshold, probabilityThreshold);
        TopologyContext topologyContext = topologyMiner.loadContext(topoCacheDir, interval, correlationThreshold, probabilityThreshold);
        if (topologyContext == null) {
            throw new RuntimeException("Topology context not found");
        }
        ShortIdDictionary dict = null;
        if (dictFile != null) {
            dict = new ShortIdDictionary(dictFile);
        }
        new UniqueTopologyBuilder(topologyContext.getTopologyHistory(), dict)
                .build(network);
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:33,代码来源:CheckSubstationUniqueToposTool.java

示例6: run

import org.joda.time.Interval; //导入方法依赖的package包/类
@Override
public void run(CommandLine line, ToolRunningContext context) throws Exception {
    Path caseFile = Paths.get(line.getOptionValue("case-file"));
    String substationId = line.getOptionValue("substation-id");
    Interval interval = Interval.parse(line.getOptionValue("interval"));
    Path dictFile = null;
    if (line.hasOption("use-short-ids-dict")) {
        dictFile = Paths.get(line.getOptionValue("use-short-ids-dict"));
    }
    double correlationThreshold = Double.parseDouble(line.getOptionValue("correlation-threshold"));
    double probabilityThreshold = Double.parseDouble(line.getOptionValue("probability-threshold"));

    Network network = Importers.loadNetwork(caseFile);
    if (network == null) {
        throw new RuntimeException("Case '" + caseFile + "' not found");
    }
    network.getStateManager().allowStateMultiThreadAccess(true);

    OfflineConfig config = OfflineConfig.load();
    try (TopologyMiner topologyMiner = config.getTopologyMinerFactoryClass().newInstance().create()) {
        Path topoCacheDir = TopologyContext.createTopoCacheDir(network, interval, correlationThreshold, probabilityThreshold);
        TopologyContext topologyContext = topologyMiner.loadContext(topoCacheDir, interval, correlationThreshold, probabilityThreshold);
        Map<String, UniqueTopology> uniqueTopologies = new UniqueTopologyBuilder(topologyContext.getTopologyHistory()).build();
        UniqueTopology uniqueTopology = uniqueTopologies.get(substationId);
        if (uniqueTopology == null) {
            throw new RuntimeException("Unique topology not found for substation " + substationId);
        }
        ShortIdDictionary dict = null;
        if (dictFile != null) {
            dict = new ShortIdDictionary(dictFile);
        }
        uniqueTopology.print(context.getOutputStream(), dict);
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:35,代码来源:PrintSubstationUniqueTopoTool.java

示例7: run

import org.joda.time.Interval; //导入方法依赖的package包/类
@Override
public void run(CommandLine line, ToolRunningContext context) throws Exception {
    OfflineConfig config = OfflineConfig.load();
    try (HistoDbClient histoDbClient = config.getHistoDbClientFactoryClass().newInstance().create()) {
        boolean statistics = line.hasOption("statistics");
        Set<HistoDbAttributeId> attrs = new LinkedHashSet<>();
        if (!statistics && line.hasOption("add-datetime")) {
            attrs.add(HistoDbMetaAttributeId.datetime);
        }
        for (String str : line.getOptionValue("attributes").split(",")) {
            attrs.add(HistoDbAttributeIdParser.parse(str));
        }
        Interval interval = Interval.parse(line.getOptionValue("interval"));
        boolean format = line.hasOption("format");
        HistoDbHorizon horizon = HistoDbHorizon.SN;
        if (line.hasOption("horizon")) {
            horizon = HistoDbHorizon.valueOf(line.getOptionValue("horizon"));
        }
        boolean async = false;
        boolean zipped = false;
        InputStream is = histoDbClient.queryCsv(statistics ? HistoQueryType.stats : HistoQueryType.data, attrs, interval, horizon, zipped, async);
        if (format) {
            format(is, zipped, context.getOutputStream());
        } else {
            try (Reader reader = createReader(is, zipped)) {
                CharStreams.copy(reader, context.getOutputStream());
            }
        }
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:31,代码来源:HistoDbPrintAttributesTool.java

示例8: convert

import org.joda.time.Interval; //导入方法依赖的package包/类
@Override
public Interval convert(String value) {
  // Interval.parse(null) creates an interval with both start and end times set to now.
  // Do something a little more reasonable.
  if (value == null) {
    throw new NullPointerException();
  }
  Interval interval = Interval.parse(value);
  // Interval does not have a way to set the time zone, so create a new interval with the
  // start and end times of the parsed interval converted to UTC.
  return new Interval(
      interval.getStart().withZone(DateTimeZone.UTC),
      interval.getEnd().withZone(DateTimeZone.UTC));
}
 
开发者ID:google,项目名称:nomulus,代码行数:15,代码来源:IntervalParameter.java

示例9: testmethods

import org.joda.time.Interval; //导入方法依赖的package包/类
@Test
public void testmethods() throws IOException, InterruptedException {
    Interval interval = Interval.parse("2013-01-14T00:00:00+01:00/2013-01-14T01:00:00+01:00");
    HistoDbClient histoDbClient = new HistoDbClientTestFactoryImpl().create(false);
    assertEquals(histoDbClient.getDbName(), "");
    assertTrue(histoDbClient.listDbs().size() == 0);
    assertTrue(histoDbClient.queryCount(interval, HistoDbHorizon.SN) == 0);
    assertEquals(histoDbClient.listAttributes(), Collections.emptyList());
    assertEquals(IOUtils.toString(histoDbClient.queryCsv(HistoQueryType.data, Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), interval, HistoDbHorizon.SN, true, true), StandardCharsets.UTF_8), "");
    assertEquals(IOUtils.toString(histoDbClient.queryCsv(HistoQueryType.data, Collections.emptySet(), interval, HistoDbHorizon.SN, true, true), StandardCharsets.UTF_8), "");
    assertNotNull(histoDbClient.queryStats(Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), interval, HistoDbHorizon.SN, true));
    assertNotNull(histoDbClient.queryStats(Collections.emptySet(), interval, HistoDbHorizon.SN, true));
}
 
开发者ID:itesla,项目名称:ipst,代码行数:14,代码来源:HistoDbDummyClientTest.java

示例10: unmarshal

import org.joda.time.Interval; //导入方法依赖的package包/类
@Override
public Interval unmarshal(String v) throws Exception {
    return Interval.parse(v);
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:5,代码来源:IntervalAdapter.java

示例11: getIntervalProperty

import org.joda.time.Interval; //导入方法依赖的package包/类
@Override
public Interval getIntervalProperty(String name) {
    return Interval.parse(getStringProperty(name));
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:5,代码来源:MapModuleConfig.java

示例12: IntervalConstant

import org.joda.time.Interval; //导入方法依赖的package包/类
public IntervalConstant(String value) {
    super(Interval.parse(value));
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:4,代码来源:IntervalConstant.java

示例13: parse

import org.joda.time.Interval; //导入方法依赖的package包/类
public static TimeInterval parse(String value) {
    return new TimeInterval(Interval.parse(value));
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:4,代码来源:TimeInterval.java

示例14: loadDefault

import org.joda.time.Interval; //导入方法依赖的package包/类
public static OnlineWorkflowParameters loadDefault() {
    ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("online-default-parameters");

    int states = config.getIntProperty("states");
    String offlineWorkflowId = config.getStringProperty("offlineWorkflowId", null);
    TimeHorizon timeHorizon = TimeHorizon.fromName(config.getStringProperty("timeHorizon").trim());
    Interval histoInterval = Interval.parse(config.getStringProperty("histoInterval"));
    String feAnalysisId = config.getStringProperty("feAnalysisId");
    double rulesPurityThreshold = Double.parseDouble(config.getStringProperty("rulesPurityThreshold"));
    boolean storeStates = config.getBooleanProperty("storeStates", false);
    boolean analyseBasecase = config.getBooleanProperty("analyseBasecase", true);
    boolean validation = config.getBooleanProperty("validation", false);
    Set<SecurityIndexType> securityIndexes = config.getEnumSetProperty("securityIndexes", SecurityIndexType.class, null);
    boolean mergeOptimized = config.getBooleanProperty("mergeOptimized", DEFAULT_MERGE_OPTIMIZED);
    float limitReduction = config.getFloatProperty("limitReduction", DEFAULT_LIMIT_REDUCTION);
    boolean handleViolationsInN = config.getBooleanProperty("handleViolationsInN", DEFAULT_HANDLE_VIOLATIONS_IN_N);
    float constraintMargin = config.getFloatProperty("constraintMargin", DEFAULT_CONSTRAINT_MARGIN);

    String caseFile = config.getStringProperty("caseFile", null);
    if (caseFile != null) {
        if ((config.getStringProperty("baseCaseDate", null) != null)
                || (config.getStringProperty("caseType", null) != null)
                || (config.getStringProperty("countries", null) != null)) {
            throw new RuntimeException("caseFile and ( baseCaseDate, caseType, countries ) are mutually exclusive options");
        }
        return new OnlineWorkflowParameters(states,
                histoInterval,
                offlineWorkflowId,
                timeHorizon,
                feAnalysisId,
                rulesPurityThreshold,
                storeStates,
                analyseBasecase,
                validation,
                securityIndexes,
                mergeOptimized,
                limitReduction,
                handleViolationsInN,
                constraintMargin,
                caseFile);
    }
    DateTime baseCaseDate = DateTime.parse(config.getStringProperty("baseCaseDate"));
    CaseType caseType = config.getEnumProperty("caseType", CaseType.class);
    Set<Country> countries = config.getEnumSetProperty("countries", Country.class);
    return new OnlineWorkflowParameters(baseCaseDate,
            states,
            histoInterval,
            offlineWorkflowId,
            timeHorizon,
            feAnalysisId,
            rulesPurityThreshold,
            storeStates,
            analyseBasecase,
            validation,
            securityIndexes,
            caseType,
            countries,
            mergeOptimized,
            limitReduction,
            handleViolationsInN,
            constraintMargin);
}
 
开发者ID:itesla,项目名称:ipst,代码行数:63,代码来源:OnlineWorkflowParameters.java

示例15: testHistoricalDataToCsvFile

import org.joda.time.Interval; //导入方法依赖的package包/类
@Test
public void testHistoricalDataToCsvFile() throws Exception {
    List<String> generatorsIds = Arrays.asList("generator1", "generator2");
    List<String> loadsIds = Arrays.asList("load1", "load2", "load3");
    Interval histoInterval = Interval.parse("2013-01-01T00:00:00+01:00/2013-01-31T23:59:00+01:00");
    
    String csvContent = String.join(System.lineSeparator(),
                                    String.join(",", 
                                                "datetime",
                                                "horizon",
                                                "forecastTime",
                                                generatorsIds.stream().map(generatorId -> String.join(",", generatorId + "_P", generatorId + "_Q")).collect(Collectors.joining(",")),
                                                loadsIds.stream().map(loadId -> String.join(",", loadId + "_P", loadId + "_Q")).collect(Collectors.joining(","))),
                                    String.join(",", 
                                                "Fri 01 Jan 2013 00:00:00 GMT","720","DACF",
                                                "0.1","-0.1","0.2","-0.2",
                                                "0.1","-0.1","0.2","-0.2","0.3","-0.3"),
                                    String.join(",", 
                                                "Fri 01 Jan 2013 00:00:00 GMT","0","SN",
                                                "0.11","-0.11","0.21","-0.21",
                                                "0.11","-0.11","0.21","-0.21","0.31","-0.31"));

    HistoDbClient histoDbClient = Mockito.mock(HistoDbClient.class);
    Mockito.when(histoDbClient.queryCsv(Matchers.eq(HistoQueryType.forecastDiff), 
                                        Matchers.any(), 
                                        Matchers.eq(histoInterval), 
                                        Matchers.eq(HistoDbHorizon.DACF), 
                                        Matchers.eq(false),
                                        Matchers.eq(false)))
           .thenReturn(new ByteArrayInputStream(csvContent.getBytes()));
    
    
    String feaCsvFileName = "forecasterrors_historicaldata.csv";
    Path workingDir = Files.createDirectory(fileSystem.getPath("/working-dir"));
    
    Path historicalDataCsvFile = workingDir.resolve(feaCsvFileName);
    FEAHistoDBFacade.historicalDataToCsvFile(histoDbClient,
                                             generatorsIds,
                                             loadsIds,
                                             histoInterval,
                                             historicalDataCsvFile);
    
    assertTrue(Files.exists(historicalDataCsvFile));
    try (InputStream expectedStream = new ByteArrayInputStream(csvContent.getBytes());
         InputStream actualStream = Files.newInputStream(historicalDataCsvFile)) {
        assertTrue(IOUtils.contentEquals(expectedStream, actualStream));
    }
    
}
 
开发者ID:itesla,项目名称:ipst,代码行数:50,代码来源:FEAHistoDBFacadeTest.java


注:本文中的org.joda.time.Interval.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。