feat: first draft of version 1
This commit is contained in:
committed by
Jonas Juselius
parent
edc6706df9
commit
aed564320c
@@ -12,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Build", "Build.fsproj", "{5A21136C-ABDA-48B9-8208-45A28CDB84CC}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "src", "src/BatHub.fsproj", "{9EBF5E9B-ED3E-4CEB-ABD4-E03F92AD45C9}"
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "src", "src/Batman.fsproj", "{9EBF5E9B-ED3E-4CEB-ABD4-E03F92AD45C9}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "test", "test\Tests.fsproj", "{E2472750-93E4-4A7B-9DF3-A39BB5D6E8C4}"
|
||||
EndProject
|
||||
@@ -4,4 +4,4 @@ RUN rm /etc/ssl/openssl.cnf
|
||||
COPY deploy/ /app
|
||||
|
||||
WORKDIR /app
|
||||
CMD /app/BatHub
|
||||
CMD /app/Batman
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# - op: add
|
||||
# path: /spec/rules/-
|
||||
# value:
|
||||
# host: BatHub.k1.itpartner.no
|
||||
# host: Batman.k1.itpartner.no
|
||||
# http:
|
||||
# paths:
|
||||
# - path: /
|
||||
@@ -22,4 +22,4 @@
|
||||
# number: 80
|
||||
# - op: add
|
||||
# path: /spec/tls/0/hosts/-
|
||||
# value: BatHub.k1.itpartner.no
|
||||
# value: Batman.k1.itpartner.no
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# - op: add
|
||||
# path: /spec/rules/-
|
||||
# value:
|
||||
# host: BatHub.k1.itpartner.no
|
||||
# host: Batman.k1.itpartner.no
|
||||
# http:
|
||||
# paths:
|
||||
# - path: /
|
||||
@@ -22,4 +22,4 @@
|
||||
# number: 80
|
||||
# - op: add
|
||||
# path: /spec/tls/0/hosts/-
|
||||
# value: BatHub.k1.itpartner.no
|
||||
# value: Batman.k1.itpartner.no
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else if contains "NodePort" .Values.service.type }}
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "BatHub.fullname" . }})
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "Batman.fullname" . }})
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
echo http://$NODE_IP:$NODE_PORT
|
||||
{{- else if contains "LoadBalancer" .Values.service.type }}
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "BatHub.fullname" . }}'
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "BatHub.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "Batman.fullname" . }}'
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "Batman.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
echo http://$SERVICE_IP:{{ .Values.service.port }}
|
||||
{{- else if contains "ClusterIP" .Values.service.type }}
|
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "BatHub.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "Batman.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
||||
echo "Visit http://127.0.0.1:8080 to use your application"
|
||||
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
|
||||
{{- end }}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "BatHub.name" -}}
|
||||
{{- define "Batman.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -11,7 +11,7 @@ Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "BatHub.fullname" -}}
|
||||
{{- define "Batman.fullname" -}}
|
||||
{{- if .Values.fullnameOverride -}}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
@@ -27,16 +27,16 @@ If release name contains chart name it will be used as a full name.
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "BatHub.chart" -}}
|
||||
{{- define "Batman.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "BatHub.labels" -}}
|
||||
helm.sh/chart: {{ include "BatHub.chart" . }}
|
||||
{{ include "BatHub.selectorLabels" . }}
|
||||
{{- define "Batman.labels" -}}
|
||||
helm.sh/chart: {{ include "Batman.chart" . }}
|
||||
{{ include "Batman.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
@@ -46,19 +46,19 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "BatHub.selectorLabels" -}}
|
||||
app: {{ include "BatHub.name" . }}
|
||||
{{- define "Batman.selectorLabels" -}}
|
||||
app: {{ include "Batman.name" . }}
|
||||
instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/name: {{ include "BatHub.name" . }}
|
||||
app.kubernetes.io/name: {{ include "Batman.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "BatHub.serviceAccountName" -}}
|
||||
{{- define "Batman.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
{{ default (include "BatHub.fullname" .) .Values.serviceAccount.name }}
|
||||
{{ default (include "Batman.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else -}}
|
||||
{{ default "default" .Values.serviceAccount.name }}
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "BatHub.fullname" . }}
|
||||
name: {{ include "Batman.fullname" . }}
|
||||
annotations:
|
||||
{{- if .Values.ci.environment }}
|
||||
app.gitlab.com/env: {{ default "" .Values.ci.environment }}
|
||||
app.gitlab.com/app: {{ default "" .Values.ci.projectPath }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "BatHub.labels" . | nindent 4 }}
|
||||
{{- include "Batman.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "BatHub.selectorLabels" . | nindent 6 }}
|
||||
{{- include "Batman.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
@@ -22,13 +22,13 @@ spec:
|
||||
app.gitlab.com/app: {{ default "" .Values.ci.projectPath }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "BatHub.selectorLabels" . | nindent 8 }}
|
||||
{{- include "Batman.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "BatHub.serviceAccountName" . }}
|
||||
serviceAccountName: {{ include "Batman.serviceAccountName" . }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
containers:
|
||||
@@ -93,13 +93,13 @@ spec:
|
||||
- name: data
|
||||
{{- if .Values.persistence.enabled }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ .Values.persistence.existingClaim | default (include "BatHub.fullname" .) }}
|
||||
claimName: {{ .Values.persistence.existingClaim | default (include "Batman.fullname" .) }}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
- name: appsettings
|
||||
secret:
|
||||
secretName: {{ template "BatHub.fullname" . }}
|
||||
secretName: {{ template "Batman.fullname" . }}
|
||||
{{- if .Values.service.https }}
|
||||
- name: tls-certificates
|
||||
secret:
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{{- if .Values.ingress.enabled -}}
|
||||
{{- $fullName := include "BatHub.fullname" . -}}
|
||||
{{- $fullName := include "Batman.fullname" . -}}
|
||||
{{- $svcPort := .Values.service.port -}}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ $fullName }}
|
||||
labels:
|
||||
{{- include "BatHub.labels" . | nindent 4 }}
|
||||
{{- include "Batman.labels" . | nindent 4 }}
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: nginx
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ template "BatHub.fullname" . }}
|
||||
name: {{ template "Batman.fullname" . }}
|
||||
{{- with .Values.persistence.annotations }}
|
||||
annotations:
|
||||
{{ toYaml . | indent 4 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{ include "BatHub.labels" . | indent 4 }}
|
||||
{{ include "Batman.labels" . | indent 4 }}
|
||||
spec:
|
||||
accessModes:
|
||||
- {{ .Values.persistence.accessMode | quote }}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "BatHub.fullname" . }}
|
||||
name: {{ include "Batman.fullname" . }}
|
||||
labels:
|
||||
{{- include "BatHub.labels" . | nindent 4 }}
|
||||
{{- include "Batman.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
@@ -12,4 +12,4 @@ spec:
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
{{- include "BatHub.selectorLabels" . | nindent 4 }}
|
||||
{{- include "Batman.selectorLabels" . | nindent 4 }}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "BatHub.serviceAccountName" . }}
|
||||
name: {{ include "Batman.serviceAccountName" . }}
|
||||
labels:
|
||||
{{ include "BatHub.labels" . | nindent 4 }}
|
||||
{{ include "Batman.labels" . | nindent 4 }}
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Default values for BatHub.
|
||||
# Default values for Batman.
|
||||
# This is a YAML-formatted file.
|
||||
# Declare variables to be passed into your templates.
|
||||
|
||||
|
||||
69
src/BBox.fs
Normal file
69
src/BBox.fs
Normal file
@@ -0,0 +1,69 @@
|
||||
module Geo
|
||||
open FSharp.Stats
|
||||
open KdTree
|
||||
open System
|
||||
|
||||
//open Microsoft.FSharp.Core
|
||||
|
||||
type BBox =
|
||||
{
|
||||
Xmin: float
|
||||
Xmax: float
|
||||
Ymin: float
|
||||
Ymax: float
|
||||
}
|
||||
|
||||
// make a kd-tree for fast nearest neighbour lookup
|
||||
let private buildTree (points: (float * float) array) =
|
||||
let tree = KdTree<float, int>(2, KdTree.Math.DoubleMath())
|
||||
points
|
||||
|> Array.iteri (fun n (x, y) -> tree.Add([| x; y |], n) |> ignore)
|
||||
tree.Balance()
|
||||
tree
|
||||
|
||||
let isInside (box:BBox) (point:float*float) =
|
||||
let x, y = point
|
||||
let inside = (x >= box.Xmin && x <= box.Xmax) && (y >= box.Ymin && y <= box.Ymax)
|
||||
inside
|
||||
|
||||
let nearestInds (points : (float*float*float)[]) (newPoints : (float*float*float)[]) =
|
||||
let px, py , pz = Array.unzip3 points
|
||||
let griddedTree = buildTree (Array.zip px py)
|
||||
let nearest =
|
||||
newPoints
|
||||
|> Array.map (fun (x, y, _) ->
|
||||
griddedTree.GetNearestNeighbours([| x; y |], 1)
|
||||
|> fun x -> x[0].Value)
|
||||
nearest
|
||||
|
||||
|
||||
let nearestPoints (data1:(float*float*float)[]) (nearestInd:int[]) =
|
||||
let nearestPoints =
|
||||
nearestInd |> Array.map (fun i -> data1.[i])
|
||||
|
||||
nearestPoints
|
||||
|
||||
let calcDistance (p1:(float*float)) (p2:(float*float)) =
|
||||
let x1, y1 = p1
|
||||
let x2, y2 = p2
|
||||
let dist = sqrt((x2-x1)**2.0 + (y2-y1)**2.0)
|
||||
dist
|
||||
|
||||
let calcDistanceMulti (points1:(float*float*float)[]) (points2:(float*float*float)[]) =
|
||||
let x1, y1, _ = Array.unzip3 points1
|
||||
let x2, y2, _ = Array.unzip3 points2
|
||||
let p1 = Array.zip x1 y1
|
||||
let p2 = Array.zip x2 y2
|
||||
let allPoints = Array.zip p1 p2
|
||||
let dist =
|
||||
allPoints
|
||||
|> Array.map (fun (x, y) -> calcDistance x y)
|
||||
dist
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
<Version>1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Settings.fs"/>
|
||||
<Compile Include="Main.fs"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Argu" Version="6.1.1"/>
|
||||
<PackageReference Include="FSharp.Data" Version="4.2.7"/>
|
||||
<PackageReference Include="FSharpPlus" Version="1.2.2"/>
|
||||
<PackageReference Include="KDTree" Version="1.4.1"/>
|
||||
<PackageReference Include="MathNet.Numerics.FSharp" Version="4.15.0"/>
|
||||
<PackageReference Include="ProjNet" Version="2.0.0"/>
|
||||
<PackageReference Include="sdslite" Version="2.2.0"/>
|
||||
<PackageReference Include="Serilog" Version="2.10.0"/>
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1"/>
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1"/>
|
||||
<PackageReference Include="Thoth.Json.Net" Version="8.0.0"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
29
src/Batman.fsproj
Normal file
29
src/Batman.fsproj
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
<Version>1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Settings.fs" />
|
||||
<Compile Include="BBox.fs" />
|
||||
<Compile Include="Files.fs" />
|
||||
<Compile Include="Main.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Argu" Version="6.1.1" />
|
||||
<PackageReference Include="FSharp.Data" Version="4.2.7" />
|
||||
<PackageReference Include="FSharp.Stats" Version="0.4.5" />
|
||||
<PackageReference Include="FSharpPlus" Version="1.2.2" />
|
||||
<PackageReference Include="KDTree" Version="1.4.1" />
|
||||
<PackageReference Include="MathNet.Numerics.FSharp" Version="4.15.0" />
|
||||
<PackageReference Include="ProjNet" Version="2.0.0" />
|
||||
<PackageReference Include="sdslite" Version="2.2.0" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" />
|
||||
<PackageReference Include="Thoth.Json.Net" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
53
src/Files.fs
Normal file
53
src/Files.fs
Normal file
@@ -0,0 +1,53 @@
|
||||
module Files
|
||||
open FSharp.Data
|
||||
open Geo
|
||||
|
||||
type FileList = CsvProvider<Schema="file (string), npoints (int), xmin (float), xmax (float), ymin (float), ymax (float)", HasHeaders=false>
|
||||
type BathyReader = CsvProvider<Schema="x (float), y (float), z (float)", Separators=",", HasHeaders=false>
|
||||
//type Primaer_data = CsvProvider<"primaer_sample.xyz", Schema="x (float), y (float), z (float), source (string)", HasHeaders=false>
|
||||
//type arrayToCsv = CsvProvider<Schema="x (float), y (float), z (float)", HasHeaders=false>
|
||||
|
||||
let writeArrayToCsv saveName a =
|
||||
a |> Array.map (fun (x, y, z) -> $"{x}; {y}; {z}") |> fun s -> System.IO.File.WriteAllLines (saveName, s)
|
||||
0
|
||||
|
||||
let readFileList (fileName:string) =
|
||||
let Fl = FileList.Load(fileName)
|
||||
Fl
|
||||
|
||||
let filesInDomain (files:FileList) box =
|
||||
let filesInside = [
|
||||
for row in files.Rows do
|
||||
if (row.Xmin <= box.Xmax) && (row.Xmax >= box.Xmin) then
|
||||
if (row.Ymin <= box.Ymax) && (row.Ymax >= box.Ymin) then
|
||||
(row.File, row.Npoints)
|
||||
]
|
||||
filesInside
|
||||
|
||||
|
||||
let readBathyFile (filePath:string) (box:BBox)=
|
||||
let Gr = BathyReader.Load filePath
|
||||
let data = [|
|
||||
for row in Gr.Rows do
|
||||
if Geo.isInside box (row.X, row.Y) then
|
||||
(row.X, row.Y, row.Z)
|
||||
|]
|
||||
data
|
||||
|
||||
//let readGriddedFile (filePath:string) (box:BBox)=
|
||||
// let Gr = BathyReader.Load filePath
|
||||
// let data = [|
|
||||
// for row in Gr.Rows do
|
||||
// if Geo.isInside box (row.X, row.Y) then
|
||||
// (row.X, row.Y, row.Z)
|
||||
// |]
|
||||
// data
|
||||
//
|
||||
//let readPrimaerFile (filePath:string) (box:BBox)=
|
||||
// let Pr = BathyReader.Load filePath
|
||||
// let data = [|
|
||||
// for row in Pr.Rows do
|
||||
// if Geo.isInside box (row.X, row.Y) then
|
||||
// (row.X, row.Y, row.Z)
|
||||
// |]
|
||||
// data
|
||||
77
src/Main.fs
77
src/Main.fs
@@ -4,8 +4,25 @@ open System
|
||||
open Serilog
|
||||
open Argu
|
||||
|
||||
open System
|
||||
open System.Data.Common
|
||||
open System.Diagnostics
|
||||
open System.Net.Security
|
||||
open FSharp.Data
|
||||
open FSharp.Stats
|
||||
open Microsoft.FSharp.Core
|
||||
open Files
|
||||
open Geo
|
||||
|
||||
open Settings
|
||||
|
||||
[<Literal>]
|
||||
let src = __SOURCE_DIRECTORY__
|
||||
let griddedFileList = src + "/data/gfiles_list.txt"
|
||||
let primaerFileList = src + "/data/pfiles_list.txt"
|
||||
let norshelfFileList = src + "/data/nfiles_list.txt"
|
||||
let coastFileList = src + "/data/cfiles_list.txt"
|
||||
|
||||
let configureSerilog () =
|
||||
LoggerConfiguration()
|
||||
.MinimumLevel.Information()
|
||||
@@ -30,15 +47,59 @@ let colorizer =
|
||||
|
||||
let errorHandler = ProcessExiter(colorizer = colorizer)
|
||||
|
||||
let getBathy fileList box =
|
||||
let flist = readFileList fileList
|
||||
let flist_inside = filesInDomain flist box
|
||||
if flist_inside |> List.isEmpty then
|
||||
printfn "No data inside domain"
|
||||
Array.empty
|
||||
else
|
||||
let fileNames, nPoints = List.unzip flist_inside
|
||||
let totalNumberOfPoints = List.sum nPoints
|
||||
printfn "Number of points: %d" totalNumberOfPoints
|
||||
let data =
|
||||
fileNames
|
||||
|> List.toArray
|
||||
|> Array.map (fun s -> readBathyFile (src + s) box)
|
||||
|> Array.fold Array.append [||]
|
||||
data
|
||||
|
||||
|
||||
let appendDataSets (data1 : (float*float*float)[]) (data2 : (float*float*float)[]) (ds : float) =
|
||||
if data1.Length > 0 then
|
||||
let nInds = nearestInds data1 data2
|
||||
let nPoints = nearestPoints data1 nInds
|
||||
let nDistance = calcDistanceMulti nPoints data2
|
||||
let notTooClose =
|
||||
Array.zip nDistance data2
|
||||
|> Array.filter (fun (dist, _) -> dist >= ds)
|
||||
|> Array.map (fun (dist, p) -> p)
|
||||
Array.append data1 notTooClose
|
||||
else
|
||||
data2
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
let parser =
|
||||
ArgumentParser.Create<Arguments>(programName = "Genesis", errorHandler = errorHandler)
|
||||
ArgumentParser.Create<Arguments>(programName = "Batman", errorHandler = errorHandler)
|
||||
let args = parser.Parse argv
|
||||
if args.Contains Foo then
|
||||
Log.Information $"{argv}"
|
||||
// let canopy =
|
||||
// args.GetResult (Foo, defaultValue = Some UI.CanopyMode.Browser)
|
||||
else
|
||||
Log.Information $"{argv}"
|
||||
0
|
||||
let saveName = argv.[0]
|
||||
let box =
|
||||
{
|
||||
Xmin = float(argv.[1])
|
||||
Xmax = float(argv.[2])
|
||||
Ymin = float(argv.[3])
|
||||
Ymax = float(argv.[4])
|
||||
}
|
||||
|
||||
let dataGridded = getBathy griddedFileList box
|
||||
let dataPrimaer = getBathy primaerFileList box
|
||||
let dataNorShelf = getBathy norshelfFileList box
|
||||
let dataCoast = getBathy coastFileList box
|
||||
|
||||
let d1 = appendDataSets dataGridded dataPrimaer 50.0
|
||||
let d2 = appendDataSets d1 dataNorShelf 2000.0
|
||||
let d3 = Array.append d2 dataCoast
|
||||
|
||||
let pg = writeArrayToCsv saveName d3
|
||||
0
|
||||
|
||||
157
src/Program.fs
Normal file
157
src/Program.fs
Normal file
@@ -0,0 +1,157 @@
|
||||
open System
|
||||
open System.Data.Common
|
||||
open System.Diagnostics
|
||||
open System.Net.Security
|
||||
open FSharp.Data
|
||||
open FSharp.Stats
|
||||
open Microsoft.FSharp.Core
|
||||
open Files
|
||||
open Geo
|
||||
|
||||
[<Literal>]
|
||||
let src = __SOURCE_DIRECTORY__
|
||||
let griddedFileList = src + "/data/gfiles_list.txt"
|
||||
let primaerFileList = src + "/data/pfiles_list.txt"
|
||||
let norshelfFileList = src + "/data/nfiles_list.txt"
|
||||
let coastFileList = src + "/data/cfiles_list.txt"
|
||||
|
||||
let getBathy fileList box =
|
||||
let flist = readFileList fileList
|
||||
let flist_inside = filesInDomain flist box
|
||||
if flist_inside |> List.isEmpty then
|
||||
printfn "No data inside domain"
|
||||
Array.empty
|
||||
else
|
||||
let fileNames, nPoints = List.unzip flist_inside
|
||||
let totalNumberOfPoints = List.sum nPoints
|
||||
printfn "Number of points: %d" totalNumberOfPoints
|
||||
let data =
|
||||
fileNames
|
||||
|> List.toArray
|
||||
|> Array.map (fun s -> readBathyFile (src + s) box)
|
||||
|> Array.fold Array.append [||]
|
||||
data
|
||||
|
||||
|
||||
let appendDataSets (data1 : (float*float*float)[]) (data2 : (float*float*float)[]) (ds : float) =
|
||||
if data1.Length > 0 then
|
||||
let nInds = nearestInds data1 data2
|
||||
let nPoints = nearestPoints data1 nInds
|
||||
let nDistance = calcDistanceMulti nPoints data2
|
||||
let notTooClose =
|
||||
Array.zip nDistance data2
|
||||
|> Array.filter (fun (dist, _) -> dist >= ds)
|
||||
|> Array.map (fun (dist, p) -> p)
|
||||
Array.append data1 notTooClose
|
||||
else
|
||||
data2
|
||||
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
let saveName = argv.[0]
|
||||
let box =
|
||||
{
|
||||
Xmin = float(argv.[1])
|
||||
Xmax = float(argv.[2])
|
||||
Ymin = float(argv.[3])
|
||||
Ymax = float(argv.[4])
|
||||
}
|
||||
|
||||
let dataGridded = getBathy griddedFileList box
|
||||
let dataPrimaer = getBathy primaerFileList box
|
||||
let dataNorShelf = getBathy norshelfFileList box
|
||||
let dataCoast = getBathy coastFileList box
|
||||
|
||||
let d1 = appendDataSets dataGridded dataPrimaer 50.0
|
||||
let d2 = appendDataSets d1 dataNorShelf 2000.0
|
||||
let d3 = Array.append d2 dataCoast
|
||||
|
||||
let pg = writeArrayToCsv saveName d3
|
||||
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// let dataSets = [|
|
||||
// (getBathy griddedFileList box, 0.0)
|
||||
// (getBathy primaerFileList box, 50.0)
|
||||
// (getBathy norshelfFileList box, 2000.0)
|
||||
// (getBathy coastFileList box, 0)
|
||||
// |]
|
||||
//
|
||||
// let finalDataSet =
|
||||
// dataSets
|
||||
// |> Array.map
|
||||
// |> Array.fold appendDataSets [||]
|
||||
//
|
||||
// // Indices of the gridded points that is closest to a primaer point
|
||||
// let nGriddedInd = nearestInds dataGridded dataPrimaer
|
||||
//
|
||||
// // The nearest gridded point to a primaer point
|
||||
// let nGriddedPoints = nearestPoints dataGridded nGriddedInd
|
||||
//
|
||||
// let nDistance = calcDistanceMulti nGriddedPoints dataPrimaer
|
||||
//
|
||||
// let notTooClosePrimaer =
|
||||
// Array.zip nDistance dataPrimaer
|
||||
// |> Array.filter (fun (dist, _) -> dist >= 50.0)
|
||||
// |> Array.map (fun (dist, p) -> p)
|
||||
//
|
||||
// printfn "%d" dataGridded.Length
|
||||
// printfn "%d" dataPrimaer.Length
|
||||
// printfn "%d" notTooClosePrimaer.Length
|
||||
//
|
||||
// let allPoints = Array.append dataGridded notTooClosePrimaer
|
||||
// let pg = writeArrayToCsv "allPoints_test.csv" allPoints
|
||||
|
||||
//let getGridded box =
|
||||
// let glist = readFileList griddedFileList
|
||||
// let glist_inside = filesInDomain glist box
|
||||
// if glist_inside |> List.isEmpty then
|
||||
// printfn "No data inside domain"
|
||||
// Array.empty
|
||||
// else
|
||||
// let fileNames, nPoints = List.unzip glist_inside
|
||||
// let totalNumberOfPoints = List.sum nPoints
|
||||
// printfn "Number of points: %d" totalNumberOfPoints
|
||||
// let data =
|
||||
// fileNames
|
||||
// |> List.toArray
|
||||
// |> Array.map (fun s -> readGriddedFile (src + s) box)
|
||||
// |> Array.fold Array.append [||]
|
||||
// data
|
||||
//
|
||||
//
|
||||
//let getPrimaer box =
|
||||
// let plist = readFileList primaerFileList
|
||||
// let plist_inside = filesInDomain plist box
|
||||
// if plist_inside |> List.isEmpty then
|
||||
// printfn "No data inside domain"
|
||||
// Array.empty
|
||||
// else
|
||||
// let fileNames, nPoints = List.unzip plist_inside
|
||||
// let totalNumberOfPoints = List.sum nPoints
|
||||
// printfn "Number of points: %d" totalNumberOfPoints
|
||||
// let data =
|
||||
// fileNames
|
||||
// |> List.toArray
|
||||
// |> Array.map (fun s -> readPrimaerFile (src + s) box)
|
||||
// |> Array.fold Array.append [||]
|
||||
// data
|
||||
//
|
||||
@@ -27,6 +27,17 @@
|
||||
"FSharp.Core": "4.7.2"
|
||||
}
|
||||
},
|
||||
"FSharp.Stats": {
|
||||
"type": "Direct",
|
||||
"requested": "[0.4.5, )",
|
||||
"resolved": "0.4.5",
|
||||
"contentHash": "YSD6SlBdBVvZDoPqfKg62f4deyRQk2qSJQ+pyB7clodvHXVH1Qrfcik0QNi3JESK9bADHCxrGuPcpMOKZKD2EA==",
|
||||
"dependencies": {
|
||||
"FSharp.Core": "6.0.1",
|
||||
"FSharpAux": "1.1.0",
|
||||
"FSharpAux.IO": "1.1.0"
|
||||
}
|
||||
},
|
||||
"FSharpPlus": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.2.2, )",
|
||||
@@ -122,6 +133,23 @@
|
||||
"FSharp.Core": "4.5.2"
|
||||
}
|
||||
},
|
||||
"FSharpAux": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.1.0",
|
||||
"contentHash": "lKxo49OYLoI27GVLXJ2sOBGazfUVZ9zowLLPUn6mHYrepaMgEdxxeZpLcQwFIfzicSoi3i09IH114GSIXy/Dgg==",
|
||||
"dependencies": {
|
||||
"FSharp.Core": "6.0.1"
|
||||
}
|
||||
},
|
||||
"FSharpAux.IO": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.1.0",
|
||||
"contentHash": "/8fFiayk7J/bmapMDCnzn9NoNhmpPskYAgluvV871fgB1hp9CXvGRaogwlwsZybrql3HmZS/flUZ+MDWb03dtg==",
|
||||
"dependencies": {
|
||||
"FSharp.Core": "6.0.1",
|
||||
"FSharpAux": "1.1.0"
|
||||
}
|
||||
},
|
||||
"MathNet.Numerics": {
|
||||
"type": "Transitive",
|
||||
"resolved": "4.15.0",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<Compile Include="Tests.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\src\BatHub.fsproj" />
|
||||
<ProjectReference Include="..\src\Batman.fsproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Expecto" Version="9.0.4" />
|
||||
|
||||
Reference in New Issue
Block a user