update calDistance function with many trajectories

This commit is contained in:
wyq 2023-04-22 17:57:55 +08:00
parent 2ab2a576da
commit cf5cacd028
8 changed files with 48 additions and 31 deletions

1
.idea/compiler.xml generated
View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="BUILD_PROCESS_HEAP_SIZE" value="2048" />
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />

View File

@ -2580,7 +2580,7 @@ public class DataFrame implements Iterable {
*
* @param fileName File name
* @param delimiter Delimiter
* @param skipRows Number of lines to skip at begining of the file
* @param skipRows Number of lines to skip at beginning of the file
* @param formatSpec Format specifiers string
* @param encoding Fle encoding
* @param indexCol Column to be used as index

View File

@ -474,7 +474,9 @@ public class Clustering {
int j;
int k;
int IND;
double[] DISS = new double[N * (N - 1) / 2];
long nl = (long) N * (N - 1) / 2;
int n = (int) nl;
double[] DISS = new double[n];
if (distanceType == DistanceType.ANGLE) {
double X0;
double Y0;
@ -528,22 +530,6 @@ public class Clustering {
//---- rather than distances.)
}
}
//For i = 0 To N - 2
//For j = i + 1 To N - 1
//IND = IOFFSET(N, i + 1, j + 1)
//DISS(IND) = 0.0
//For k = 0 To M - 1
//DISS(IND) = DISS(IND) + (DATA(i, k) - DATA(j, k)) ^ 2
//Next
//If IOPT = 1 Then
//DISS(IND) = DISS(IND) / 2
//End If
//---- (Above is done for the case of the min. var. method
//---- where merging criteria are defined in terms of variances
//---- rather than distances.)
//Next
//Next
}
return DISS;
@ -556,7 +542,9 @@ public class Clustering {
int j;
int k;
int IND;
double[] DISS = new double[N * (N - 1) / 2];
long nl = (long) N * (N - 1) / 2;
int n = (int) nl;
double[] DISS = new double[n];
for (i = 0; i <= N - 2; i++) {
for (j = i + 1; j <= N - 1; j++) {
IND = IOFFSET(N, i + 1, j + 1);

View File

@ -1,32 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="milconfig.xml" Type="configurefile">
<Path OpenPath="D:\Working\MIScript\Jython\mis\dataframe">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\linalg"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\interpolate"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\FY"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\weather"/>
<Path OpenPath="D:\Working\MIScript\Jython\mis\traj">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\funny"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\legend"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamplot"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamslice"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\ascii"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\traj"/>
</Path>
<File>
<OpenedFiles>
<OpenedFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\dataframe\reindex_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\chart\legend\legend_title.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamslice\streamslice_xy_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\traj\cluster_1.py"/>
</OpenedFiles>
<RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\dataframe\reindex_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\chart\legend\legend_title.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamslice\streamslice_xy_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\traj\cluster_1.py"/>
</RecentFiles>
</File>
<Font>

View File

@ -558,7 +558,7 @@ class Axes3DGL(Axes3D):
def streamslice(self, *args, **kwargs):
"""
Plot stream lines slice in 3D axes.
Plot streamlines slice in 3D axes.
:param x: (*array_like*) X coordinate array.
:param y: (*array_like*) Y coordinate array.

View File

@ -90,6 +90,12 @@
<artifactId>jakarta.annotation-api</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
<!--<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>

View File

@ -0,0 +1,20 @@
package org.meteoinfo.ndarray;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ArrayLengthTest {
@Test
public void testLength() {
int n = 6296;
long n1 = (long) n * (n - 1) / 2;
int n2 = (int) n1;
System.out.println(n2);
double[] d = new double[n2];
double[][] d1 = new double[n / 2][(n - 1)];
System.out.println(d.length);
assertEquals(d.length, d1.length * d1[0].length);
}
}