update array creation functions

This commit is contained in:
wyq 2019-11-04 23:33:37 +08:00
parent e577045d08
commit 051e6b9a33
1716 changed files with 15804 additions and 12843 deletions

View File

@ -1,140 +1,140 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.l2fprod:l2fprod-common-all:0.1" level="project" />
<orderEntry type="library" name="Maven: edu.ucar:netcdfAll:5.1.0" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.10" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphics2d:2.4" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphicsbase:2.4" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-io:2.2.2" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphicsio-ps:2.4" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphicsio:2.4" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphicsio-tests:2.4" level="project" />
<orderEntry type="library" name="Maven: org.scilab.forge:jlatexmath:1.0.7" level="project" />
<orderEntry type="library" name="Maven: org.scilab.forge:jlatexmath-font-greek:1.0.7" level="project" />
<orderEntry type="library" name="Maven: org.scilab.forge:jlatexmath-font-cyrillic:1.0.7" level="project" />
<orderEntry type="library" name="Maven: org.python:jython-standalone:2.7.1" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphicsio-emf:2.4" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphicsio-pdf:2.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-imaging:1.0-alpha1" level="project" />
<orderEntry type="library" name="Maven: com.toedter:jcalendar:1.4" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-experimental:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-core:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-ddense:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-dsparse:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-zdense:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-simple:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-fdense:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-cdense:0.32" level="project" />
<orderEntry type="library" name="Maven: org.mozilla.intl:chardet:1.0" level="project" />
<orderEntry type="library" name="Maven: org.meteothink:wContour:1.6.1" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-util:2.0.2" level="project" />
<orderEntry type="library" name="Maven: org.netbeans:openide-lookup:1.9-patched-1.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: org.locationtech.jts:jts-core:1.16.1" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:itextpdf:5.5.7" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt-main:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-android-aarch64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-android-armv6:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-linux-amd64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-linux-armv6:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-linux-armv6hf:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-linux-i586:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-macosx-universal:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-solaris-amd64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-solaris-i586:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-windows-amd64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-windows-i586:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all-main:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-android-aarch64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-android-armv6:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-linux-amd64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-linux-armv6:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-linux-armv6hf:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-linux-i586:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-macosx-universal:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-solaris-amd64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-solaris-i586:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-windows-amd64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-windows-i586:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.locationtech.proj4j:proj4j:1.1.0" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native-platform:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas-platform:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:android-arm:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:android-arm64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:android-x86:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:android-x86_64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:ios-arm64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:ios-x86_64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-x86:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-x86_64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-armhf:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-arm64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-ppc64le:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:macosx-x86_64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:windows-x86:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:windows-x86_64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl-platform:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl:linux-x86:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl:linux-x86_64:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl:macosx-x86_64:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl:windows-x86:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl:windows-x86_64:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl-dnn-platform:0.20-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl-dnn:0.20-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl-dnn:linux-x86_64:0.20-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl-dnn:macosx-x86_64:0.20-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl-dnn:windows-x86_64:0.20-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:javacpp:1.5.1-1" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native-api:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-buffer:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-api:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: com.jakewharton.byteunits:byteunits:0.9.1" level="project" />
<orderEntry type="library" name="Maven: com.google.flatbuffers:flatbuffers-java:1.10.0" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:protobuf:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.objenesis:objenesis:2.6" level="project" />
<orderEntry type="library" name="Maven: com.github.oshi:oshi-core:3.4.2" level="project" />
<orderEntry type="library" name="Maven: net.java.dev.jna:jna-platform:4.3.0" level="project" />
<orderEntry type="library" name="Maven: net.java.dev.jna:jna:4.3.0" level="project" />
<orderEntry type="library" name="Maven: org.threeten:threetenbp:1.3.3" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.21" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:jackson:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: commons-net:commons-net:3.1" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-context:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-common:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:guava:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.18" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" name="Maven: net.ericaro:neoitertools:1.0.0" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:android-arm:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:android-arm64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:android-x86:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:android-x86_64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:ios-arm64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:ios-x86_64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:linux-x86_64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:macosx-x86_64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:windows-x86_64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:linux-ppc64le:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:linux-armhf:1.0.0-beta5" level="project" />
</component>
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.l2fprod:l2fprod-common-all:0.1" level="project" />
<orderEntry type="library" name="Maven: edu.ucar:netcdfAll:5.1.0" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.10" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphics2d:2.4" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphicsbase:2.4" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-io:2.2.2" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphicsio-ps:2.4" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphicsio:2.4" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphicsio-tests:2.4" level="project" />
<orderEntry type="library" name="Maven: org.scilab.forge:jlatexmath:1.0.7" level="project" />
<orderEntry type="library" name="Maven: org.scilab.forge:jlatexmath-font-greek:1.0.7" level="project" />
<orderEntry type="library" name="Maven: org.scilab.forge:jlatexmath-font-cyrillic:1.0.7" level="project" />
<orderEntry type="library" name="Maven: org.python:jython-standalone:2.7.1" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphicsio-emf:2.4" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-graphicsio-pdf:2.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-imaging:1.0-alpha1" level="project" />
<orderEntry type="library" name="Maven: com.toedter:jcalendar:1.4" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-experimental:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-core:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-ddense:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-dsparse:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-zdense:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-simple:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-fdense:0.32" level="project" />
<orderEntry type="library" name="Maven: org.ejml:ejml-cdense:0.32" level="project" />
<orderEntry type="library" name="Maven: org.mozilla.intl:chardet:1.0" level="project" />
<orderEntry type="library" name="Maven: org.meteothink:wContour:1.6.1" level="project" />
<orderEntry type="library" name="Maven: org.freehep:freehep-util:2.0.2" level="project" />
<orderEntry type="library" name="Maven: org.netbeans:openide-lookup:1.9-patched-1.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: org.locationtech.jts:jts-core:1.16.1" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:itextpdf:5.5.7" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt-main:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-android-aarch64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-android-armv6:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-linux-amd64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-linux-armv6:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-linux-armv6hf:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-linux-i586:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-macosx-universal:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-solaris-amd64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-solaris-i586:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-windows-amd64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.gluegen:gluegen-rt:natives-windows-i586:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all-main:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-android-aarch64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-android-armv6:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-linux-amd64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-linux-armv6:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-linux-armv6hf:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-linux-i586:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-macosx-universal:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-solaris-amd64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-solaris-i586:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-windows-amd64:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.jogamp.jogl:jogl-all:natives-windows-i586:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.locationtech.proj4j:proj4j:1.1.0" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native-platform:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas-platform:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:android-arm:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:android-arm64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:android-x86:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:android-x86_64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:ios-arm64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:ios-x86_64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-x86:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-x86_64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-armhf:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-arm64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-ppc64le:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:macosx-x86_64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:windows-x86:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:windows-x86_64:0.3.6-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl-platform:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl:linux-x86:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl:linux-x86_64:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl:macosx-x86_64:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl:windows-x86:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl:windows-x86_64:2019.4-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl-dnn-platform:0.20-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl-dnn:0.20-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl-dnn:linux-x86_64:0.20-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl-dnn:macosx-x86_64:0.20-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:mkl-dnn:windows-x86_64:0.20-1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:javacpp:1.5.1-1" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native-api:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-buffer:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-api:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: com.jakewharton.byteunits:byteunits:0.9.1" level="project" />
<orderEntry type="library" name="Maven: com.google.flatbuffers:flatbuffers-java:1.10.0" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:protobuf:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.objenesis:objenesis:2.6" level="project" />
<orderEntry type="library" name="Maven: com.github.oshi:oshi-core:3.4.2" level="project" />
<orderEntry type="library" name="Maven: net.java.dev.jna:jna-platform:4.3.0" level="project" />
<orderEntry type="library" name="Maven: net.java.dev.jna:jna:4.3.0" level="project" />
<orderEntry type="library" name="Maven: org.threeten:threetenbp:1.3.3" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.21" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:jackson:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: commons-net:commons-net:3.1" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-context:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-common:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:guava:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.18" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" name="Maven: net.ericaro:neoitertools:1.0.0" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:android-arm:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:android-arm64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:android-x86:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:android-x86_64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:ios-arm64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:ios-x86_64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:linux-x86_64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:macosx-x86_64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:windows-x86_64:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:linux-ppc64le:1.0.0-beta5" level="project" />
<orderEntry type="library" name="Maven: org.nd4j:nd4j-native:linux-armhf:1.0.0-beta5" level="project" />
</component>
</module>

View File

@ -1,94 +1,94 @@
/* Copyright 2012 Yaqiang Wang,
* yaqiang.wang@gmail.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*/
package org.meteoinfo.data.meteodata;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author yaqiang
*/
public class MeteoDataDrawSet {
// <editor-fold desc="Variables">
private String _weatherType = "All Weather";
// </editor-fold>
// <editor-fold desc="Constructor">
// </editor-fold>
// <editor-fold desc="Get Set Methods">
/**
* Get weather type
*
* @return Weather type
*/
public String getWeatherType() {
return _weatherType;
}
/**
* Set weather type
*
* @param weatherType Weather type
*/
public void setWeatherType(String weatherType) {
_weatherType = weatherType;
}
// </editor-fold>
// <editor-fold desc="Methods">
/**
* Get weather list
*
* @param weatherType Weather type
* @return Weather list
*/
public static List<Integer> getWeatherTypes(String weatherType) {
List<Integer> weatherList = new ArrayList<Integer>();
int i;
int[] weathers = new int[1];
if (weatherType.equals("All Weather")) {
weathers = new int[96];
for (i = 4; i < 100; i++) {
weathers[i - 4] = i;
}
} else if (weatherType.equals("SDS")) {
weathers = new int[]{6, 7, 8, 9, 30, 31, 32, 33, 34, 35};
} else if (weatherType.equals("SDS, Haze")) {
weathers = new int[]{5, 6, 7, 8, 9, 30, 31, 32, 33, 34, 35};
} else if (weatherType.equals("Smoke, Haze, Mist")) {
weathers = new int[]{4, 5, 10};
} else if (weatherType.equals("Smoke")) {
weathers = new int[]{4};
} else if (weatherType.equals("Haze")) {
weathers = new int[]{5};
} else if (weatherType.equals("Mist")) {
weathers = new int[]{10};
} else if (weatherType.equals("Fog")) {
weathers = new int[10];
for (i = 40; i < 50; i++) {
weathers[i - 40] = i;
}
}
for (int w : weathers) {
weatherList.add(w);
}
return weatherList;
}
// </editor-fold>
}
/* Copyright 2012 Yaqiang Wang,
* yaqiang.wang@gmail.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*/
package org.meteoinfo.data.meteodata;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author yaqiang
*/
public class MeteoDataDrawSet {
// <editor-fold desc="Variables">
private String _weatherType = "All Weather";
// </editor-fold>
// <editor-fold desc="Constructor">
// </editor-fold>
// <editor-fold desc="Get Set Methods">
/**
* Get weather type
*
* @return Weather type
*/
public String getWeatherType() {
return _weatherType;
}
/**
* Set weather type
*
* @param weatherType Weather type
*/
public void setWeatherType(String weatherType) {
_weatherType = weatherType;
}
// </editor-fold>
// <editor-fold desc="Methods">
/**
* Get weather list
*
* @param weatherType Weather type
* @return Weather list
*/
public static List<Integer> getWeatherTypes(String weatherType) {
List<Integer> weatherList = new ArrayList<>();
int i;
int[] weathers = new int[1];
if (weatherType.equals("All Weather")) {
weathers = new int[96];
for (i = 4; i < 100; i++) {
weathers[i - 4] = i;
}
} else if (weatherType.equals("SDS")) {
weathers = new int[]{6, 7, 8, 9, 30, 31, 32, 33, 34, 35};
} else if (weatherType.equals("SDS, Haze")) {
weathers = new int[]{5, 6, 7, 8, 9, 30, 31, 32, 33, 34, 35};
} else if (weatherType.equals("Smoke, Haze, Mist")) {
weathers = new int[]{4, 5, 10};
} else if (weatherType.equals("Smoke")) {
weathers = new int[]{4};
} else if (weatherType.equals("Haze")) {
weathers = new int[]{5};
} else if (weatherType.equals("Mist")) {
weathers = new int[]{10};
} else if (weatherType.equals("Fog")) {
weathers = new int[10];
for (i = 40; i < 50; i++) {
weathers[i - 40] = i;
}
}
for (int w : weathers) {
weatherList.add(w);
}
return weatherList;
}
// </editor-fold>
}

View File

@ -1,185 +1,185 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.meteoinfo.data.meteodata.netcdf;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.meteoinfo.data.meteodata.Attribute;
import org.meteoinfo.data.meteodata.Variable;
import org.meteoinfo.ndarray.Array;
import org.meteoinfo.ndarray.ArrayStructure;
import org.meteoinfo.ndarray.DataType;
import org.meteoinfo.ndarray.Dimension;
import org.meteoinfo.ndarray.InvalidRangeException;
import org.meteoinfo.ndarray.Section;
/**
*
* @author Yaqiang Wang
*/
public class NCUtil {
/**
* Convert netcdf data type to meteothink data type
* @param ncDataType Netcdf data type
* @return MeteoThink data type
*/
public static DataType convertDataType(ucar.ma2.DataType ncDataType) {
DataType dataType = DataType.getType(ncDataType.toString());
return dataType;
}
/**
* Convert meteothink data type to netcdf data type
* @param dataType MeteoThink data type
* @return Netcdf data type
*/
public static ucar.ma2.DataType convertDataType(DataType dataType) {
ucar.ma2.DataType ncDataType = ucar.ma2.DataType.getType(dataType.toString());
return ncDataType;
}
/**
* Convert netcdf array to meteothink array
* @param ncArray Netcdf array
* @return MeteoThink array
*/
public static Array convertArray(ucar.ma2.Array ncArray) {
if (ncArray == null) {
return null;
}
DataType dt = convertDataType(ncArray.getDataType());
if (dt == DataType.OBJECT && ncArray.getObject(0).getClass() == String.class){
dt = DataType.STRING;
}
Array array = null;
switch (dt) {
case STRUCTURE:
case SEQUENCE:
array = new ArrayStructure(ncArray.getShape());
((ArrayStructure)array).setArrayObject(ncArray);
break;
default:
array = Array.factory(dt, ncArray.getShape(), ncArray.getStorage());
break;
}
return array;
}
/**
* Convert meteothink array to netcdf array
* @param array MeteoThink array
* @return Netcdf array
*/
public static ucar.ma2.Array convertArray(Array array) {
ucar.ma2.Array ncArray = null;
switch (array.getDataType()) {
case STRUCTURE:
case SEQUENCE:
ncArray = (ucar.ma2.Array)((ArrayStructure)array).getArrayObject();
break;
default:
ncArray = ucar.ma2.Array.factory(convertDataType(array.getDataType()), array.getShape(), array.getStorage());
break;
}
return ncArray;
}
/**
* Convert from netcdf dimension to meteothink dimension
* @param ncDim Netcdf dimension
* @return MeteoThink dimension
*/
public static Dimension convertDimension(ucar.nc2.Dimension ncDim) {
Dimension dim = new Dimension();
dim.setShortName(ncDim.getShortName());
dim.setLength(ncDim.getLength());
dim.setUnlimited(ncDim.isUnlimited());
dim.setShared(ncDim.isShared());
dim.setVariableLength(ncDim.isVariableLength());
return dim;
}
/**
* Convert netcdf dimensions to meteothink dimensions
* @param ncDims Netcdf dimensions
* @return MeteoThink dimensions
*/
public static List<Dimension> convertDimensions(List<ucar.nc2.Dimension> ncDims) {
List<Dimension> dims = new ArrayList<>();
for (ucar.nc2.Dimension ncDim : ncDims) {
dims.add(convertDimension(ncDim));
}
return dims;
}
/**
* Convert netcdf attribute to meteothink attribute
* @param ncAttr Netcdf attribute
* @return MeteoThink attribute
*/
public static Attribute convertAttribute(ucar.nc2.Attribute ncAttr) {
Attribute attr = new Attribute(ncAttr.getShortName());
attr.setStringValue(ncAttr.getStringValue());
attr.setValues(convertArray(ncAttr.getValues()));
return attr;
}
/**
* Convert meoteoinfo attribute to netcdf attribute
* @param attr Attribute
* @return MeteoInfo attribute
*/
public static ucar.nc2.Attribute convertAttribute(Attribute attr) {
ucar.nc2.Attribute ncAttr = new ucar.nc2.Attribute(attr.getShortName(), convertArray(attr.getValues()));
return ncAttr;
}
/**
* Convert netcdf variable to meteothink variable
* @param ncVar Netcdf variable
* @return MeteoThink variable
*/
public static Variable convertVariable(ucar.nc2.Variable ncVar) {
Variable var = new Variable();
var.setName(ncVar.getShortName());
var.setDataType(convertDataType(ncVar.getDataType()));
var.setDescription(ncVar.getDescription());
var.setDimensions(convertDimensions(ncVar.getDimensions()));
for (ucar.nc2.Attribute ncAttr : ncVar.getAttributes()) {
var.addAttribute(convertAttribute(ncAttr));
}
var.setUnits(ncVar.getUnitsString());
return var;
}
/**
* Convert netcdf section to meteothink section
* @param ncSection Netcdf section
* @return Meteothink section
*/
public static Section convertSection(ucar.ma2.Section ncSection) {
try {
Section section = new Section(ncSection.getOrigin(), ncSection.getShape(), ncSection.getStride());
return section;
} catch (InvalidRangeException ex) {
Logger.getLogger(NCUtil.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.meteoinfo.data.meteodata.netcdf;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.meteoinfo.data.meteodata.Attribute;
import org.meteoinfo.data.meteodata.Variable;
import org.meteoinfo.ndarray.Array;
import org.meteoinfo.ndarray.ArrayStructure;
import org.meteoinfo.ndarray.DataType;
import org.meteoinfo.ndarray.Dimension;
import org.meteoinfo.ndarray.InvalidRangeException;
import org.meteoinfo.ndarray.Section;
/**
*
* @author Yaqiang Wang
*/
public class NCUtil {
/**
* Convert netcdf data type to meteothink data type
* @param ncDataType Netcdf data type
* @return MeteoThink data type
*/
public static DataType convertDataType(ucar.ma2.DataType ncDataType) {
DataType dataType = DataType.getType(ncDataType.toString());
return dataType;
}
/**
* Convert meteothink data type to netcdf data type
* @param dataType MeteoThink data type
* @return Netcdf data type
*/
public static ucar.ma2.DataType convertDataType(DataType dataType) {
ucar.ma2.DataType ncDataType = ucar.ma2.DataType.getType(dataType.toString());
return ncDataType;
}
/**
* Convert netcdf array to meteothink array
* @param ncArray Netcdf array
* @return MeteoThink array
*/
public static Array convertArray(ucar.ma2.Array ncArray) {
if (ncArray == null) {
return null;
}
DataType dt = convertDataType(ncArray.getDataType());
if (dt == DataType.OBJECT && ncArray.getObject(0).getClass() == String.class){
dt = DataType.STRING;
}
Array array = null;
switch (dt) {
case STRUCTURE:
case SEQUENCE:
array = new ArrayStructure(ncArray.getShape());
((ArrayStructure)array).setArrayObject(ncArray);
break;
default:
array = Array.factory(dt, ncArray.getShape(), ncArray.getStorage());
break;
}
return array;
}
/**
* Convert meteothink array to netcdf array
* @param array MeteoThink array
* @return Netcdf array
*/
public static ucar.ma2.Array convertArray(Array array) {
ucar.ma2.Array ncArray = null;
switch (array.getDataType()) {
case STRUCTURE:
case SEQUENCE:
ncArray = (ucar.ma2.Array)((ArrayStructure)array).getArrayObject();
break;
default:
ncArray = ucar.ma2.Array.factory(convertDataType(array.getDataType()), array.getShape(), array.getStorage());
break;
}
return ncArray;
}
/**
* Convert from netcdf dimension to meteothink dimension
* @param ncDim Netcdf dimension
* @return MeteoThink dimension
*/
public static Dimension convertDimension(ucar.nc2.Dimension ncDim) {
Dimension dim = new Dimension();
dim.setShortName(ncDim.getShortName());
dim.setLength(ncDim.getLength());
dim.setUnlimited(ncDim.isUnlimited());
dim.setShared(ncDim.isShared());
dim.setVariableLength(ncDim.isVariableLength());
return dim;
}
/**
* Convert netcdf dimensions to meteothink dimensions
* @param ncDims Netcdf dimensions
* @return MeteoThink dimensions
*/
public static List<Dimension> convertDimensions(List<ucar.nc2.Dimension> ncDims) {
List<Dimension> dims = new ArrayList<>();
for (ucar.nc2.Dimension ncDim : ncDims) {
dims.add(convertDimension(ncDim));
}
return dims;
}
/**
* Convert netcdf attribute to meteothink attribute
* @param ncAttr Netcdf attribute
* @return MeteoThink attribute
*/
public static Attribute convertAttribute(ucar.nc2.Attribute ncAttr) {
Attribute attr = new Attribute(ncAttr.getShortName());
attr.setStringValue(ncAttr.getStringValue());
attr.setValues(convertArray(ncAttr.getValues()));
return attr;
}
/**
* Convert meoteoinfo attribute to netcdf attribute
* @param attr Attribute
* @return MeteoInfo attribute
*/
public static ucar.nc2.Attribute convertAttribute(Attribute attr) {
ucar.nc2.Attribute ncAttr = new ucar.nc2.Attribute(attr.getShortName(), convertArray(attr.getValues()));
return ncAttr;
}
/**
* Convert netcdf variable to meteothink variable
* @param ncVar Netcdf variable
* @return MeteoThink variable
*/
public static Variable convertVariable(ucar.nc2.Variable ncVar) {
Variable var = new Variable();
var.setName(ncVar.getShortName());
var.setDataType(convertDataType(ncVar.getDataType()));
var.setDescription(ncVar.getDescription());
var.setDimensions(convertDimensions(ncVar.getDimensions()));
for (ucar.nc2.Attribute ncAttr : ncVar.getAttributes()) {
var.addAttribute(convertAttribute(ncAttr));
}
var.setUnits(ncVar.getUnitsString());
return var;
}
/**
* Convert netcdf section to meteothink section
* @param ncSection Netcdf section
* @return Meteothink section
*/
public static Section convertSection(ucar.ma2.Section ncSection) {
try {
Section section = new Section(ncSection.getOrigin(), ncSection.getShape(), ncSection.getStride());
return section;
} catch (InvalidRangeException ex) {
Logger.getLogger(NCUtil.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
}

View File

@ -1,415 +1,485 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.meteoinfo.image;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.imageio.ImageIO;
import javax.imageio.metadata.IIOInvalidTreeException;
import javax.imageio.metadata.IIOMetadata;
import javax.imageio.metadata.IIOMetadataNode;
import org.apache.commons.imaging.Imaging;
import org.apache.commons.imaging.ImageFormat;
import org.apache.commons.imaging.ImageFormats;
import org.apache.commons.imaging.ImageReadException;
import org.apache.commons.imaging.ImageWriteException;
import org.meteoinfo.ndarray.Array;
import org.meteoinfo.ndarray.DataType;
import org.meteoinfo.ndarray.Index;
/**
*
* @author Yaqiang Wang
*/
public class ImageUtil {
private final static double INCH_2_CM = 2.54;
/**
* Read RGB array data from image file
* @param fileName Image file name
* @return RGB array data
* @throws java.io.IOException
* @throws ImageReadException
*/
public static Array imageRead(String fileName) throws IOException, ImageReadException{
String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
BufferedImage image;
if (extension.equalsIgnoreCase("jpg") || extension.equalsIgnoreCase("jpeg")){
image = ImageIO.read(new File(fileName));
} else {
image = Imaging.getBufferedImage(new File(fileName));
}
return imageRead(image);
}
/**
* Read RGB array data from image
* @param image Image
* @return RGB array data
*/
public static Array imageRead(BufferedImage image){
int xn = image.getWidth();
int yn = image.getHeight();
Array r = Array.factory(DataType.INT, new int[]{yn, xn, 3});
Index index = r.getIndex();
int rgb;
Color color;
for (int i = 0; i < yn; i++){
for (int j = 0; j < xn; j++){
rgb = image.getRGB(j, yn - i - 1);
color = new Color(rgb);
r.setInt(index.set(i, j, 0), color.getRed());
r.setInt(index.set(i, j, 1), color.getGreen());
r.setInt(index.set(i, j, 2), color.getBlue());
}
}
return r;
}
/**
* Load image from image file
* @param fileName Image file name
* @return Image
* @throws java.io.IOException
* @throws ImageReadException
*/
public static BufferedImage imageLoad(String fileName) throws IOException, ImageReadException{
String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
BufferedImage image;
if (extension.equalsIgnoreCase("jpg") || extension.equalsIgnoreCase("jpeg")){
image = ImageIO.read(new File(fileName));
} else {
image = Imaging.getBufferedImage(new File(fileName));
}
return image;
}
/**
* Create image from RGB(A) data array
* @param data RGB(A) data array
* @return Image
*/
public static BufferedImage createImage(Array data) {
int width, height;
width = data.getShape()[1];
height = data.getShape()[0];
Color undefColor = Color.white;
BufferedImage aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Color color;
Index index = data.getIndex();
boolean isAlpha = data.getShape()[2] == 4;
if (data.getDataType() == DataType.FLOAT || data.getDataType() == DataType.DOUBLE){
float r, g, b;
if (isAlpha) {
float a;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
r = data.getFloat(index.set(i, j, 0));
g = data.getFloat(index.set(i, j, 1));
b = data.getFloat(index.set(i, j, 2));
a = data.getFloat(index.set(i, j, 3));
if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b) || Double.isNaN(a)) {
color = undefColor;
} else {
color = new Color(r, g, b, a);
}
aImage.setRGB(j, height - i - 1, color.getRGB());
}
}
} else {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
r = data.getFloat(index.set(i, j, 0));
g = data.getFloat(index.set(i, j, 1));
b = data.getFloat(index.set(i, j, 2));
if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b)) {
color = undefColor;
} else {
color = new Color(r, g, b);
}
aImage.setRGB(j, height - i - 1, color.getRGB());
}
}
}
} else {
int r, g, b;
if (isAlpha) {
int a;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
r = data.getInt(index.set(i, j, 0));
g = data.getInt(index.set(i, j, 1));
b = data.getInt(index.set(i, j, 2));
a = data.getInt(index.set(i, j, 3));
if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b) || Double.isNaN(a)) {
color = undefColor;
} else {
color = new Color(r, g, b, a);
}
aImage.setRGB(j, height - i - 1, color.getRGB());
}
}
} else {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
r = data.getInt(index.set(i, j, 0));
g = data.getInt(index.set(i, j, 1));
b = data.getInt(index.set(i, j, 2));
if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b)) {
color = undefColor;
} else {
color = new Color(r, g, b);
}
aImage.setRGB(j, height - i - 1, color.getRGB());
}
}
}
}
return aImage;
}
/**
* Save image into a file
* @param data RGB(A) data array
* @param fileName Output image file name
* @throws IOException
* @throws ImageWriteException
*/
public static void imageSave(Array data, String fileName) throws IOException, ImageWriteException{
String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
BufferedImage image = createImage(data);
ImageFormat format = getImageFormat(extension);
if (format == ImageFormats.JPEG){
ImageIO.write(image, extension, new File(fileName));
} else {
Imaging.writeImage(image, new File(fileName), format, null);
}
}
/**
* Save image into a file
* @param image Image
* @param fileName Output image file name
* @throws IOException
* @throws ImageWriteException
*/
public static void imageSave(BufferedImage image, String fileName) throws IOException, ImageWriteException{
String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
ImageFormat format = getImageFormat(extension);
if (format == ImageFormats.JPEG){
ImageIO.write(image, extension, new File(fileName));
} else {
Imaging.writeImage(image, new File(fileName), format, null);
}
}
private static ImageFormat getImageFormat(String ext){
ImageFormat format = ImageFormats.PNG;
switch(ext.toLowerCase()){
case "gif":
format = ImageFormats.GIF;
break;
case "jpeg":
case "jpg":
format = ImageFormats.JPEG;
break;
case "bmp":
format = ImageFormats.BMP;
break;
case "tif":
case "tiff":
format = ImageFormats.TIFF;
break;
}
return format;
}
/**
* Count none-zero points with window size
* @param data Input data
* @param size Window size
* @return Count array
*/
public static Array count(Array data, int size){
int ny = data.getShape()[0];
int nx = data.getShape()[1];
int skip = size / 2;
int ii, jj, n;
Array r = Array.factory(DataType.INT, data.getShape());
for (int i = 0; i < ny; i++){
if (i < skip || i >= ny - skip){
for (int j = 0; j < nx; j++){
r.setInt(i * nx + j, 0);
}
} else {
for (int j = 0; j < nx; j++){
if (j < skip || j >= nx - skip){
r.setInt(i * nx + j, 0);
} else {
n = 0;
for (ii = i - skip; ii <= i + skip; ii++){
for (jj = j - skip; jj <= j + skip; jj++){
if (data.getDouble(ii * nx + jj) > 0){
n += 1;
}
}
}
r.setInt(i * nx + j, n);
}
}
}
}
return r;
}
/**
* Calculate mean value with window size
* @param data Input data
* @param size Window size
* @param positive Only calculate the positive value or not.
* @return Mean array
*/
public static Array mean(Array data, int size, boolean positive){
int ny = data.getShape()[0];
int nx = data.getShape()[1];
int skip = size / 2;
double sum;
int ii, jj, n;
Array r = Array.factory(data.getDataType(), data.getShape());
for (int i = 0; i < ny; i++){
if (i < skip || i >= ny - skip){
for (int j = 0; j < nx; j++){
r.setObject(i * nx + j, 0);
}
} else {
for (int j = 0; j < nx; j++){
if (j < skip || j >= nx - skip){
r.setObject(i * nx + j, 0);
} else {
n = 0;
sum = 0;
if (positive){
for (ii = i - skip; ii <= i + skip; ii++){
for (jj = j - skip; jj <= j + skip; jj++){
if (data.getDouble(ii * nx + jj) > 0){
sum += data.getDouble(ii * nx + jj);
n += 1;
}
}
}
} else {
for (ii = i - skip; ii <= i + skip; ii++){
for (jj = j - skip; jj <= j + skip; jj++){
if (!Double.isNaN(data.getDouble(ii * nx + jj))){
sum += data.getDouble(ii * nx + jj);
n += 1;
}
}
}
}
if (n > 0)
r.setObject(i * nx + j, sum / n);
else
r.setObject(i * nx + j, 0);
}
}
}
}
return r;
}
/**
* Create gif animator file from image files
*
* @param inImageFiles Input image files
* @param outGifFile Output gif file
* @param delay Delay time in milliseconds between each frame
* @param repeat Repeat times, 0 means unlimite repeat
*/
public static void createGifAnimator(List<String> inImageFiles, String outGifFile, int delay, int repeat) {
try {
AnimatedGifEncoder e = new AnimatedGifEncoder();
e.setRepeat(0);
e.setDelay(delay);
e.start(outGifFile);
for (String infn : inImageFiles){
e.addFrame(ImageIO.read(new File(infn)));
}
e.finish();
} catch (Exception e) {
System.out.println("Create gif animator failed:");
e.printStackTrace();
}
}
/**
* Create gif animator file from image files
*
* @param inImageFiles Input image files
* @param outGifFile Output gif file
* @param delay Delay time in milliseconds between each frame
*/
public static void createGifAnimator(List<String> inImageFiles, String outGifFile, int delay) {
createGifAnimator(inImageFiles, outGifFile, delay, 0);
}
/**
* Create gif animator file from image files
* @param infiles Input image files
* @param outfile Output gif file
* @param delay Delay time in milliseconds between each frame
*/
public static void createGifAnimator(File[] infiles, File outfile, int delay) {
try {
AnimatedGifEncoder e = new AnimatedGifEncoder();
e.setRepeat(0);
e.setDelay(delay);
e.start(outfile.getCanonicalPath());
for (File inf : infiles){
e.addFrame(ImageIO.read(inf));
}
e.finish();
} catch (Exception e) {
System.out.println("Create gif animator failed:");
e.printStackTrace();
}
}
/**
* Set DPI
* @param metadata IIOMetadata
* @param dpi DPI
* @throws IIOInvalidTreeException
*/
public static void setDPI(IIOMetadata metadata, float dpi) throws IIOInvalidTreeException {
// for PMG, it's dots per millimeter
double dotsPerMilli = 1.0 * dpi / 10 / INCH_2_CM;
IIOMetadataNode horiz = new IIOMetadataNode("HorizontalPixelSize");
horiz.setAttribute("value", Double.toString(dotsPerMilli));
IIOMetadataNode vert = new IIOMetadataNode("VerticalPixelSize");
vert.setAttribute("value", Double.toString(dotsPerMilli));
IIOMetadataNode dim = new IIOMetadataNode("Dimension");
dim.appendChild(horiz);
dim.appendChild(vert);
IIOMetadataNode root = new IIOMetadataNode("javax_imageio_1.0");
root.appendChild(dim);
metadata.mergeTree("javax_imageio_1.0", root);
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.meteoinfo.image;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import javax.imageio.metadata.IIOInvalidTreeException;
import javax.imageio.metadata.IIOMetadata;
import javax.imageio.metadata.IIOMetadataNode;
import org.apache.commons.imaging.Imaging;
import org.apache.commons.imaging.ImageFormat;
import org.apache.commons.imaging.ImageFormats;
import org.apache.commons.imaging.ImageReadException;
import org.apache.commons.imaging.ImageWriteException;
import org.meteoinfo.math.ArrayMath;
import org.meteoinfo.ndarray.*;
/**
*
* @author Yaqiang Wang
*/
public class ImageUtil {
private final static double INCH_2_CM = 2.54;
/**
* Read RGB array data from image file
* @param fileName Image file name
* @return RGB array data
* @throws java.io.IOException
* @throws ImageReadException
*/
public static Array imageRead(String fileName) throws IOException, ImageReadException{
String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
BufferedImage image;
if (extension.equalsIgnoreCase("jpg") || extension.equalsIgnoreCase("jpeg")){
image = ImageIO.read(new File(fileName));
} else {
image = Imaging.getBufferedImage(new File(fileName));
}
return imageRead(image);
}
/**
* Read RGB array data from image
* @param image Image
* @return RGB array data
*/
public static Array imageRead(BufferedImage image){
int xn = image.getWidth();
int yn = image.getHeight();
Array r = Array.factory(DataType.INT, new int[]{yn, xn, 3});
Index index = r.getIndex();
int rgb;
Color color;
for (int i = 0; i < yn; i++){
for (int j = 0; j < xn; j++){
rgb = image.getRGB(j, yn - i - 1);
color = new Color(rgb);
r.setInt(index.set(i, j, 0), color.getRed());
r.setInt(index.set(i, j, 1), color.getGreen());
r.setInt(index.set(i, j, 2), color.getBlue());
}
}
return r;
}
/**
* Load image from image file
* @param fileName Image file name
* @return Image
* @throws java.io.IOException
* @throws ImageReadException
*/
public static BufferedImage imageLoad(String fileName) throws IOException, ImageReadException{
String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
BufferedImage image;
if (extension.equalsIgnoreCase("jpg") || extension.equalsIgnoreCase("jpeg")){
image = ImageIO.read(new File(fileName));
} else {
image = Imaging.getBufferedImage(new File(fileName));
}
return image;
}
/**
* Create image from RGB(A) data array
* @param data RGB(A) data array
* @return Image
*/
public static BufferedImage createImage(Array data) {
int width, height;
width = data.getShape()[1];
height = data.getShape()[0];
Color undefColor = Color.white;
BufferedImage aImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Color color;
Index index = data.getIndex();
boolean isAlpha = data.getShape()[2] == 4;
if (data.getDataType() == DataType.FLOAT || data.getDataType() == DataType.DOUBLE){
float r, g, b;
if (isAlpha) {
float a;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
r = data.getFloat(index.set(i, j, 0));
g = data.getFloat(index.set(i, j, 1));
b = data.getFloat(index.set(i, j, 2));
a = data.getFloat(index.set(i, j, 3));
if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b) || Double.isNaN(a)) {
color = undefColor;
} else {
color = new Color(r, g, b, a);
}
aImage.setRGB(j, height - i - 1, color.getRGB());
}
}
} else {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
r = data.getFloat(index.set(i, j, 0));
g = data.getFloat(index.set(i, j, 1));
b = data.getFloat(index.set(i, j, 2));
if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b)) {
color = undefColor;
} else {
color = new Color(r, g, b);
}
aImage.setRGB(j, height - i - 1, color.getRGB());
}
}
}
} else {
int r, g, b;
if (isAlpha) {
int a;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
r = data.getInt(index.set(i, j, 0));
g = data.getInt(index.set(i, j, 1));
b = data.getInt(index.set(i, j, 2));
a = data.getInt(index.set(i, j, 3));
if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b) || Double.isNaN(a)) {
color = undefColor;
} else {
color = new Color(r, g, b, a);
}
aImage.setRGB(j, height - i - 1, color.getRGB());
}
}
} else {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
r = data.getInt(index.set(i, j, 0));
g = data.getInt(index.set(i, j, 1));
b = data.getInt(index.set(i, j, 2));
if (Double.isNaN(r) || Double.isNaN(g) || Double.isNaN(b)) {
color = undefColor;
} else {
color = new Color(r, g, b);
}
aImage.setRGB(j, height - i - 1, color.getRGB());
}
}
}
}
return aImage;
}
/**
* Save image into a file
* @param data RGB(A) data array
* @param fileName Output image file name
* @throws IOException
* @throws ImageWriteException
*/
public static void imageSave(Array data, String fileName) throws IOException, ImageWriteException{
String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
BufferedImage image = createImage(data);
ImageFormat format = getImageFormat(extension);
if (format == ImageFormats.JPEG){
ImageIO.write(image, extension, new File(fileName));
} else {
Imaging.writeImage(image, new File(fileName), format, null);
}
}
/**
* Save image into a file
* @param image Image
* @param fileName Output image file name
* @throws IOException
* @throws ImageWriteException
*/
public static void imageSave(BufferedImage image, String fileName) throws IOException, ImageWriteException{
String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
ImageFormat format = getImageFormat(extension);
if (format == ImageFormats.JPEG){
ImageIO.write(image, extension, new File(fileName));
} else {
Imaging.writeImage(image, new File(fileName), format, null);
}
}
private static ImageFormat getImageFormat(String ext){
ImageFormat format = ImageFormats.PNG;
switch(ext.toLowerCase()){
case "gif":
format = ImageFormats.GIF;
break;
case "jpeg":
case "jpg":
format = ImageFormats.JPEG;
break;
case "bmp":
format = ImageFormats.BMP;
break;
case "tif":
case "tiff":
format = ImageFormats.TIFF;
break;
}
return format;
}
/**
* Count none-zero points with window size
* @param data Input data
* @param size Window size
* @return Count array
*/
public static Array count(Array data, int size){
int ny = data.getShape()[0];
int nx = data.getShape()[1];
int skip = size / 2;
int ii, jj, n;
Array r = Array.factory(DataType.INT, data.getShape());
for (int i = 0; i < ny; i++){
if (i < skip || i >= ny - skip){
for (int j = 0; j < nx; j++){
r.setInt(i * nx + j, 0);
}
} else {
for (int j = 0; j < nx; j++){
if (j < skip || j >= nx - skip){
r.setInt(i * nx + j, 0);
} else {
n = 0;
for (ii = i - skip; ii <= i + skip; ii++){
for (jj = j - skip; jj <= j + skip; jj++){
if (data.getDouble(ii * nx + jj) > 0){
n += 1;
}
}
}
r.setInt(i * nx + j, n);
}
}
}
}
return r;
}
/**
* Calculate mean value with window size
* @param data Input data
* @param size Window size
* @param positive Only calculate the positive value or not.
* @return Mean array
*/
public static Array mean(Array data, int size, boolean positive){
int ny = data.getShape()[0];
int nx = data.getShape()[1];
int skip = size / 2;
double sum;
int ii, jj, n;
Array r = Array.factory(data.getDataType(), data.getShape());
for (int i = 0; i < ny; i++){
if (i < skip || i >= ny - skip){
for (int j = 0; j < nx; j++){
r.setObject(i * nx + j, 0);
}
} else {
for (int j = 0; j < nx; j++){
if (j < skip || j >= nx - skip){
r.setObject(i * nx + j, 0);
} else {
n = 0;
sum = 0;
if (positive){
for (ii = i - skip; ii <= i + skip; ii++){
for (jj = j - skip; jj <= j + skip; jj++){
if (data.getDouble(ii * nx + jj) > 0){
sum += data.getDouble(ii * nx + jj);
n += 1;
}
}
}
} else {
for (ii = i - skip; ii <= i + skip; ii++){
for (jj = j - skip; jj <= j + skip; jj++){
if (!Double.isNaN(data.getDouble(ii * nx + jj))){
sum += data.getDouble(ii * nx + jj);
n += 1;
}
}
}
}
if (n > 0)
r.setObject(i * nx + j, sum / n);
else
r.setObject(i * nx + j, 0);
}
}
}
}
return r;
}
/**
* Calculate a multi-dimensional minimum filter.
* @param data Input data
* @param size Window size
* @return Minimum filter array
*/
public static Array minimumFilter(Array data, int size) throws InvalidRangeException {
int[] shape = data.getShape();
int half = size / 2;
double min;
int n = data.getRank();
Array r = Array.factory(data.getDataType(), shape);
IndexIterator iter = data.getIndexIterator();
IndexIterator riter = r.getIndexIterator();
int[] counter;
List<Range> ranges;
int si, ei;
Array temp;
while(iter.hasNext()) {
iter.next();
counter = iter.getCurrentCounter();
ranges = new ArrayList<>();
for (int i = 0; i < n; i++) {
si = (counter[i] - half) >= 0 ? counter[i] - half : 0;
ei = (counter[i] + half < shape[i]) ? counter[i] + half : shape[i] - 1;
ranges.add(new Range(si, ei));
}
temp = data.section(ranges);
min = ArrayMath.min(temp);
riter.setDoubleNext(min);
}
return r;
}
/**
* Calculate a multi-dimensional maximum filter.
* @param data Input data
* @param size Window size
* @return Maximum filter array
*/
public static Array maximumFilter(Array data, int size) throws InvalidRangeException {
int[] shape = data.getShape();
int half = size / 2;
double max;
int n = data.getRank();
Array r = Array.factory(data.getDataType(), shape);
IndexIterator iter = data.getIndexIterator();
IndexIterator riter = r.getIndexIterator();
int[] counter;
List<Range> ranges;
int si, ei;
Array temp;
while(iter.hasNext()) {
iter.next();
counter = iter.getCurrentCounter();
ranges = new ArrayList<>();
for (int i = 0; i < n; i++) {
si = (counter[i] - half) >= 0 ? counter[i] - half : 0;
ei = (counter[i] + half < shape[i]) ? counter[i] + half : shape[i] - 1;
ranges.add(new Range(si, ei));
}
temp = data.section(ranges);
max = ArrayMath.max(temp);
riter.setDoubleNext(max);
}
return r;
}
/**
* Create gif animator file from image files
*
* @param inImageFiles Input image files
* @param outGifFile Output gif file
* @param delay Delay time in milliseconds between each frame
* @param repeat Repeat times, 0 means unlimite repeat
*/
public static void createGifAnimator(List<String> inImageFiles, String outGifFile, int delay, int repeat) {
try {
AnimatedGifEncoder e = new AnimatedGifEncoder();
e.setRepeat(0);
e.setDelay(delay);
e.start(outGifFile);
for (String infn : inImageFiles){
e.addFrame(ImageIO.read(new File(infn)));
}
e.finish();
} catch (Exception e) {
System.out.println("Create gif animator failed:");
e.printStackTrace();
}
}
/**
* Create gif animator file from image files
*
* @param inImageFiles Input image files
* @param outGifFile Output gif file
* @param delay Delay time in milliseconds between each frame
*/
public static void createGifAnimator(List<String> inImageFiles, String outGifFile, int delay) {
createGifAnimator(inImageFiles, outGifFile, delay, 0);
}
/**
* Create gif animator file from image files
* @param infiles Input image files
* @param outfile Output gif file
* @param delay Delay time in milliseconds between each frame
*/
public static void createGifAnimator(File[] infiles, File outfile, int delay) {
try {
AnimatedGifEncoder e = new AnimatedGifEncoder();
e.setRepeat(0);
e.setDelay(delay);
e.start(outfile.getCanonicalPath());
for (File inf : infiles){
e.addFrame(ImageIO.read(inf));
}
e.finish();
} catch (Exception e) {
System.out.println("Create gif animator failed:");
e.printStackTrace();
}
}
/**
* Set DPI
* @param metadata IIOMetadata
* @param dpi DPI
* @throws IIOInvalidTreeException
*/
public static void setDPI(IIOMetadata metadata, float dpi) throws IIOInvalidTreeException {
// for PMG, it's dots per millimeter
double dotsPerMilli = 1.0 * dpi / 10 / INCH_2_CM;
IIOMetadataNode horiz = new IIOMetadataNode("HorizontalPixelSize");
horiz.setAttribute("value", Double.toString(dotsPerMilli));
IIOMetadataNode vert = new IIOMetadataNode("VerticalPixelSize");
vert.setAttribute("value", Double.toString(dotsPerMilli));
IIOMetadataNode dim = new IIOMetadataNode("Dimension");
dim.appendChild(horiz);
dim.appendChild(vert);
IIOMetadataNode root = new IIOMetadataNode("javax_imageio_1.0");
root.appendChild(dim);
metadata.mergeTree("javax_imageio_1.0", root);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,165 @@
package org.meteoinfo.math.random;
import org.apache.commons.math3.random.MersenneTwister;
import org.meteoinfo.ndarray.Array;
import org.meteoinfo.ndarray.DataType;
import java.util.List;
import java.util.Random;
public class MTRandom extends MersenneTwister {
/**
* Constructor
*/
public MTRandom() {
super();
}
/**
* Constructor
* @param seed Seed
*/
public MTRandom(int seed) {
super(seed);
}
/**
* Get random array - one dimension
*
* @param n Array length
* @return Result array
*/
public Array rand(int n) {
Array r = Array.factory(DataType.DOUBLE, new int[]{n});
for (int i = 0; i < r.getSize(); i++) {
r.setDouble(i, this.nextDouble());
}
return r;
}
/**
* Get random array
*
* @param shape Shape
* @return Array Result array
*/
public Array rand(List<Integer> shape) {
int[] ashape = new int[shape.size()];
for (int i = 0; i < shape.size(); i++) {
ashape[i] = shape.get(i);
}
Array a = Array.factory(DataType.DOUBLE, ashape);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, this.nextDouble());
}
return a;
}
/**
* Get random value
*
* @return Random value
*/
public double randn() {
return this.nextGaussian();
}
/**
* Get random array - one dimension
*
* @param n Array length
* @return Result array
*/
public Array randn(int n) {
Array r = Array.factory(DataType.DOUBLE, new int[]{n});
for (int i = 0; i < r.getSize(); i++) {
r.setDouble(i, this.nextGaussian());
}
return r;
}
/**
* Get random array
*
* @param shape Shape
* @return Array Result array
*/
public Array randn(List<Integer> shape) {
int[] ashape = new int[shape.size()];
for (int i = 0; i < shape.size(); i++) {
ashape[i] = shape.get(i);
}
Array a = Array.factory(DataType.DOUBLE, ashape);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, this.nextGaussian());
}
return a;
}
/**
* Get random int value
*
* @param bound Highest value
* @return Random int value
*/
public int randint(int bound) {
return this.nextInt(bound);
}
/**
* Get random integer array
*
* @param bound Highest value
* @param n Array length
* @return Array Result array
*/
public Array randint(int bound, int n) {
Array a = Array.factory(DataType.INT, new int[]{n});
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, this.nextInt(bound));
}
return a;
}
/**
* Get random integer array
*
* @param bound Highest value
* @param shape Shape
* @return Array Result array
*/
public Array randint(int bound, List<Integer> shape) {
int[] ashape = new int[shape.size()];
for (int i = 0; i < shape.size(); i++) {
ashape[i] = shape.get(i);
}
Array a = Array.factory(DataType.INT, ashape);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, this.nextInt(bound));
}
return a;
}
/**
* Fisher-Yates algorithm with O(n) time complexity
* Permutes the given array
*
* @param x array to be shuffled
*/
public void suffle(Array x) {
for (int i = (int)x.getSize() - 1; i > 0; i--) {
int index = this.nextInt(i);
// swap
Object tmp = x.getObject(index);
x.setObject(index, x.getObject(i));
x.setObject(i, tmp);
}
}
}

View File

@ -1,235 +1,235 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.meteoinfo.math;
import java.util.List;
import java.util.Random;
import org.apache.commons.math3.random.RandomDataGenerator;
import org.meteoinfo.ndarray.Array;
import org.meteoinfo.ndarray.DataType;
/**
*
* @author Yaqiang Wang
*/
public class RandomUtil {
public static long seed = 1;
public static boolean useSeed = false;
/**
* Get random value
*
* @return Random value
*/
public static double rand() {
Random r = new Random();
if (useSeed)
r.setSeed(seed);
return r.nextDouble();
}
/**
* Get random array - one dimension
*
* @param n Array length
* @return Result array
*/
public static Array rand(int n) {
Array r = Array.factory(DataType.DOUBLE, new int[]{n});
Random rd = new Random();
if (useSeed)
rd.setSeed(seed);
for (int i = 0; i < r.getSize(); i++) {
r.setDouble(i, rd.nextDouble());
}
return r;
}
/**
* Get random array
*
* @param shape Shape
* @return Array Result array
*/
public static Array rand(List<Integer> shape) {
int[] ashape = new int[shape.size()];
for (int i = 0; i < shape.size(); i++) {
ashape[i] = shape.get(i);
}
Array a = Array.factory(DataType.DOUBLE, ashape);
Random rd = new Random();
if (useSeed)
rd.setSeed(seed);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, rd.nextDouble());
}
return a;
}
/**
* Get random value
*
* @return Random value
*/
public static double randn() {
Random r = new Random();
if (useSeed)
r.setSeed(seed);
return r.nextGaussian();
}
/**
* Get random array - one dimension
*
* @param n Array length
* @return Result array
*/
public static Array randn(int n) {
Array r = Array.factory(DataType.DOUBLE, new int[]{n});
Random rd = new Random();
if (useSeed)
rd.setSeed(seed);
for (int i = 0; i < r.getSize(); i++) {
r.setDouble(i, rd.nextGaussian());
}
return r;
}
/**
* Get random array
*
* @param shape Shape
* @return Array Result array
*/
public static Array randn(List<Integer> shape) {
int[] ashape = new int[shape.size()];
for (int i = 0; i < shape.size(); i++) {
ashape[i] = shape.get(i);
}
Array a = Array.factory(DataType.DOUBLE, ashape);
Random rd = new Random();
if (useSeed)
rd.setSeed(seed);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, rd.nextGaussian());
}
return a;
}
/**
* Get random int value
*
* @param bound Highest value
* @return Random int value
*/
public static int randint(int bound) {
Random r = new Random();
if (useSeed)
r.setSeed(seed);
return r.nextInt(bound);
}
/**
* Get random integer array
*
* @param bound Highest value
* @param n Array length
* @return Array Result array
*/
public static Array randint(int bound, int n) {
Array a = Array.factory(DataType.INT, new int[]{n});
Random rd = new Random();
if (useSeed)
rd.setSeed(seed);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, rd.nextInt(bound));
}
return a;
}
/**
* Get random integer array
*
* @param bound Highest value
* @param shape Shape
* @return Array Result array
*/
public static Array randint(int bound, List<Integer> shape) {
int[] ashape = new int[shape.size()];
for (int i = 0; i < shape.size(); i++) {
ashape[i] = shape.get(i);
}
Array a = Array.factory(DataType.INT, ashape);
Random rd = new Random();
if (useSeed)
rd.setSeed(seed);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, rd.nextInt(bound));
}
return a;
}
/**
* Get random data from a Poisson distribution
* @param mean Poisson mean
* @return Random value
*/
public static double poisson(double mean){
RandomDataGenerator rdg = new RandomDataGenerator();
if (useSeed)
rdg.reSeed(seed);
return rdg.nextPoisson(mean);
}
/**
* Get random data from a Poisson distribution
*
* @param mean Poisson mean
* @param n Array length
* @return Array Result array
*/
public static Array poisson(double mean, int n) {
Array a = Array.factory(DataType.INT, new int[]{n});
RandomDataGenerator rd = new RandomDataGenerator();
if (useSeed)
rd.reSeed(seed);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, rd.nextPoisson(mean));
}
return a;
}
/**
* Get random data from a Poisson distribution
*
* @param mean Poisson mean
* @param shape Shape
* @return Array Result array
*/
public static Array poisson(double mean, List<Integer> shape) {
int[] ashape = new int[shape.size()];
for (int i = 0; i < shape.size(); i++) {
ashape[i] = shape.get(i);
}
Array a = Array.factory(DataType.INT, ashape);
RandomDataGenerator rd = new RandomDataGenerator();
if (useSeed)
rd.reSeed(seed);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, rd.nextPoisson(mean));
}
return a;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.meteoinfo.math.random;
import java.util.List;
import java.util.Random;
import org.apache.commons.math3.random.RandomDataGenerator;
import org.meteoinfo.ndarray.Array;
import org.meteoinfo.ndarray.DataType;
/**
*
* @author Yaqiang Wang
*/
public class RandomUtil {
public static long seed = 1;
public static boolean useSeed = false;
/**
* Get random value
*
* @return Random value
*/
public static double rand() {
Random r = new Random();
if (useSeed)
r.setSeed(seed);
return r.nextDouble();
}
/**
* Get random array - one dimension
*
* @param n Array length
* @return Result array
*/
public static Array rand(int n) {
Array r = Array.factory(DataType.DOUBLE, new int[]{n});
Random rd = new Random();
if (useSeed)
rd.setSeed(seed);
for (int i = 0; i < r.getSize(); i++) {
r.setDouble(i, rd.nextDouble());
}
return r;
}
/**
* Get random array
*
* @param shape Shape
* @return Array Result array
*/
public static Array rand(List<Integer> shape) {
int[] ashape = new int[shape.size()];
for (int i = 0; i < shape.size(); i++) {
ashape[i] = shape.get(i);
}
Array a = Array.factory(DataType.DOUBLE, ashape);
Random rd = new Random();
if (useSeed)
rd.setSeed(seed);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, rd.nextDouble());
}
return a;
}
/**
* Get random value
*
* @return Random value
*/
public static double randn() {
Random r = new Random();
if (useSeed)
r.setSeed(seed);
return r.nextGaussian();
}
/**
* Get random array - one dimension
*
* @param n Array length
* @return Result array
*/
public static Array randn(int n) {
Array r = Array.factory(DataType.DOUBLE, new int[]{n});
Random rd = new Random();
if (useSeed)
rd.setSeed(seed);
for (int i = 0; i < r.getSize(); i++) {
r.setDouble(i, rd.nextGaussian());
}
return r;
}
/**
* Get random array
*
* @param shape Shape
* @return Array Result array
*/
public static Array randn(List<Integer> shape) {
int[] ashape = new int[shape.size()];
for (int i = 0; i < shape.size(); i++) {
ashape[i] = shape.get(i);
}
Array a = Array.factory(DataType.DOUBLE, ashape);
Random rd = new Random();
if (useSeed)
rd.setSeed(seed);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, rd.nextGaussian());
}
return a;
}
/**
* Get random int value
*
* @param bound Highest value
* @return Random int value
*/
public static int randint(int bound) {
Random r = new Random();
if (useSeed)
r.setSeed(seed);
return r.nextInt(bound);
}
/**
* Get random integer array
*
* @param bound Highest value
* @param n Array length
* @return Array Result array
*/
public static Array randint(int bound, int n) {
Array a = Array.factory(DataType.INT, new int[]{n});
Random rd = new Random();
if (useSeed)
rd.setSeed(seed);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, rd.nextInt(bound));
}
return a;
}
/**
* Get random integer array
*
* @param bound Highest value
* @param shape Shape
* @return Array Result array
*/
public static Array randint(int bound, List<Integer> shape) {
int[] ashape = new int[shape.size()];
for (int i = 0; i < shape.size(); i++) {
ashape[i] = shape.get(i);
}
Array a = Array.factory(DataType.INT, ashape);
Random rd = new Random();
if (useSeed)
rd.setSeed(seed);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, rd.nextInt(bound));
}
return a;
}
/**
* Get random data from a Poisson distribution
* @param mean Poisson mean
* @return Random value
*/
public static double poisson(double mean){
RandomDataGenerator rdg = new RandomDataGenerator();
if (useSeed)
rdg.reSeed(seed);
return rdg.nextPoisson(mean);
}
/**
* Get random data from a Poisson distribution
*
* @param mean Poisson mean
* @param n Array length
* @return Array Result array
*/
public static Array poisson(double mean, int n) {
Array a = Array.factory(DataType.INT, new int[]{n});
RandomDataGenerator rd = new RandomDataGenerator();
if (useSeed)
rd.reSeed(seed);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, rd.nextPoisson(mean));
}
return a;
}
/**
* Get random data from a Poisson distribution
*
* @param mean Poisson mean
* @param shape Shape
* @return Array Result array
*/
public static Array poisson(double mean, List<Integer> shape) {
int[] ashape = new int[shape.size()];
for (int i = 0; i < shape.size(); i++) {
ashape[i] = shape.get(i);
}
Array a = Array.factory(DataType.INT, ashape);
RandomDataGenerator rd = new RandomDataGenerator();
if (useSeed)
rd.reSeed(seed);
for (int i = 0; i < a.getSize(); i++) {
a.setDouble(i, rd.nextPoisson(mean));
}
return a;
}
}

View File

@ -388,7 +388,10 @@ public class ArrayBoolean extends Array {
}
public void setObject(int index, Object value) {
storage[index] = (Boolean) value;
if (value instanceof Integer)
storage[index] = ((Integer) value == 1);
else
storage[index] = (Boolean) value;
}
/**

View File

@ -367,7 +367,7 @@ public class ArrayComplex extends Array {
}
public Object getObject(int index) {
return getDouble(index);
return getComplex(index);
}
public void setObject(int index, Object value) {

View File

@ -1,68 +1,68 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.meteoinfo.util;
import java.io.IOException;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.net.URLClassLoader;
import java.net.URL;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Yaqiang Wang
*/
public class ClassPathHacker {
private static final Class[] parameters = new Class[]{URL.class};
/**
* Add a jar file
*
* @param s Jar file path
* @throws IOException
*/
public static void addFile(String s) throws IOException {
File f = new File(s);
addFile(f);
}
/**
* Add a jar file
*
* @param f Jar file object
* @throws IOException
*/
public static void addFile(File f) throws IOException {
addURL(f.toURI().toURL());
}
/**
* Add URL
*
* @param u The URL
* @throws IOException
*/
public static void addURL(URL u) throws IOException {
URL urls [] = {};
URLClassLoader sysloader = new URLClassLoader(urls);
Class sysclass = URLClassLoader.class;
try {
Method method = sysclass.getDeclaredMethod("addURL", parameters);
method.setAccessible(true);
method.invoke(sysloader, new Object[]{u});
} catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException t) {
t.printStackTrace();
throw new IOException("Error, could not add URL to system classloader");
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.meteoinfo.util;
import java.io.IOException;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.net.URLClassLoader;
import java.net.URL;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Yaqiang Wang
*/
public class ClassPathHacker {
private static final Class[] parameters = new Class[]{URL.class};
/**
* Add a jar file
*
* @param s Jar file path
* @throws IOException
*/
public static void addFile(String s) throws IOException {
File f = new File(s);
addFile(f);
}
/**
* Add a jar file
*
* @param f Jar file object
* @throws IOException
*/
public static void addFile(File f) throws IOException {
addURL(f.toURI().toURL());
}
/**
* Add URL
*
* @param u The URL
* @throws IOException
*/
public static void addURL(URL u) throws IOException {
URL urls [] = {};
URLClassLoader sysloader = new URLClassLoader(urls);
Class sysclass = URLClassLoader.class;
try {
Method method = sysclass.getDeclaredMethod("addURL", parameters);
method.setAccessible(true);
method.invoke(sysloader, new Object[]{u});
} catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException t) {
t.printStackTrace();
throw new IOException("Error, could not add URL to system classloader");
}
}
}

View File

@ -1,35 +1,35 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.meteoinfo.util;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
/**
*
* @author wyq
*/
public class MyClassLoader extends URLClassLoader {
public MyClassLoader() {
super(new URL[]{});
}
public MyClassLoader(URL[] urls) {
super(urls);
}
public MyClassLoader(URL[] urls, ClassLoader parent) {
super(urls, parent);
}
public void addFile (String path) throws MalformedURLException
{
String urlPath = "jar:file://" + path + "!/";
addURL (new URL (urlPath));
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.meteoinfo.util;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
/**
*
* @author wyq
*/
public class MyClassLoader extends URLClassLoader {
public MyClassLoader() {
super(new URL[]{});
}
public MyClassLoader(URL[] urls) {
super(urls);
}
public MyClassLoader(URL[] urls, ClassLoader parent) {
super(urls, parent);
}
public void addFile (String path) throws MalformedURLException
{
String urlPath = "jar:file://" + path + "!/";
addURL (new URL (urlPath));
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Some files were not shown because too many files have changed in this diff Show More