Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible web app, vector rendering, and different radar formats #8

Open
SteepAtticStairs opened this issue Jun 6, 2022 · 5 comments

Comments

@SteepAtticStairs
Copy link

SteepAtticStairs commented Jun 6, 2022

I've been using this project for a bit and it is very useful. However, there are some changes that I propose and would love to hear feedback on.

First, these are the commands I use to enter the project:

git clone https://github.com/bwiggs/go-nexrad.git
cd go-nexrad && cd cmd && cd nexrad-render

# these two commands are just to download radar files
aws s3 cp --no-sign-request s3://noaa-nexrad-level2/2017/08/25/KCRP/KCRP20170825_235733_V06 .
aws s3 cp --no-sign-request s3://noaa-nexrad-level2/2022/04/18/KLWX/KLWX20220418_153931_V06 .

go get -u golang.org/x/sys

Then, there is an issue with velocity rendering, though reflectivity works fine. I fix it by doing:
in cmd/nexrad-render/main.go, around line 181, replace

// if product != "ref" {
// elv = 2 // uhhh, why did i do this again?
// }
label := fmt.Sprintf("%s %f %s VCP:%d %s %s", ar2.VolumeHeader.ICAO, ar2.ElevationScans[2][0].Header.ElevationAngle, strings.ToUpper(product), ar2.RadarStatus.VolumeCoveragePatternNum, ar2.VolumeHeader.FileName(), ar2.VolumeHeader.Date().Format(time.RFC3339))
render(out, ar2.ElevationScans[elv], label)

with

if product == "vel" {
	elv = 2 // uhhh, why did i do this again?
}
render(out, ar2.ElevationScans[elv], fmt.Sprintf("%s - %s", ar2.VolumeHeader.ICAO, ar2.VolumeHeader.Date()))

this is the commit.
I can then do

go run . -f KCRP20170825_235733_V06 -s 2048 -p vel
# OR
go build
./nexrad-render -f KCRP20170825_235733_V06 -s 2048 -p vel

which works awesome. The first change I propose is wondering what the issue is with the velocity rendering, and why I have to change the code as detailed above?

My second proposal is providing an option, perhaps another command flag, to render the output as a vector image, e.g. svg. You already use the draw2d library with draw2dimg.SaveToPngFile(), so i figured that using vector graphics would make the time loading the image on the user’s end much quicker. I figured you could do draw2dimg.SaveToSvgFile() to accomplish this.

My third proposal is porting this project to a web app. This would mean that one could upload a radar file, specify command flags (e.g. -s 2048 and -p vel), and then it will give you a png image to download, exactly how it runs on the command line.

My first thought was WebAssembly, but I am unsure how to interact with a CLI application such as this one using that framework. I found several guides online, but they are for simple applications where the program just takes user input and then logs the result to the console.

I then stumbled upon this where someone managed to do something very similar with PDF processing. The full repo for that article is found here.

I was wondering if it would be possible to make a rudimentary web application out of your program, using either these things that I have listed, or another way you know of. CSS / styling wouldn't be necessary as this would just be, as I said, rudimentary.

I love your program and will continue to use it, but in the meantime I hope you have time to read and consider these suggestions.

Cheers!
Andrew

@SteepAtticStairs SteepAtticStairs changed the title Possible web app and velocity cleanup Possible web app, vector rendering, and velocity cleanup Jun 6, 2022
@bwiggs
Copy link
Owner

bwiggs commented Jun 7, 2022

Hey Andrew, glad you found this library/toolset helpful!

First, these are the commands I use to enter the project:

Looks fine. If you just want the binaries locally, and you're using go >= 1.17 you can use go install to grab the binaries. Make sure your path includes ~/go/bin as that's where they go by default.

$ go install github.com/bwiggs/go-nexrad/cmd/nexrad-render@latest

go get -u golang.org/x/sys

I up'd all the deps this evening. Pull latest and the need to do that go get should be resolved.

Then, there is an issue with velocity rendering, though reflectivity works fine

Spent some time looking into this tonight. It seem that some elevation levels do not contain VEL data. Ex: see this google discussion. That answers the uhhh, why did i do this again? question. hah! You can now pass in -e to nexrad-render and it will use that elevation level, it defaults to 1.

nexrad-render needs better error reporting and checks around this case, rather than failing completely.

I added a new utility to the repo to inspect these ar2 files. Checkout cmd/nexrad-tui. The elevation list on the left will tell you what products are in it. Consider this a hacky work in progress!

My second proposal is providing an option, perhaps another command flag, to render the output as a vector image

Neat idea! Might be nice to be able to tell it what kind of file to produce via command line argument. Any interest in working on a PR for this?

My third proposal is porting this project to a web app.

WASM would be neat andcould return some sort of BLOB with either the encoded image file or the radar data in something easy to use with js/canvas for custom rendering.

I'm pretty limited on time to work on that but it sounds feasible. Interested in hacking on a PR? Would be happy to review/help.

@SteepAtticStairs
Copy link
Author

SteepAtticStairs commented Jun 8, 2022

Thanks for getting back so quickly!

I also wonder how different Level 3 files are from Level 2, in their difficulty to write a parser / plotter for? I personally use Hydrometer Classification and Vertically Integrated Liquid a lot, which are both level 3 products. If they're not that different, that would be something to consider, maybe something even I could do, with my near-nothing knowledge of Go 😅

I feel like one difficult aspect would be getting the color schemes for each product.

@SteepAtticStairs
Copy link
Author

SteepAtticStairs commented Jun 8, 2022

I also realized that all Level 2 files before June 1, 2016 had a different format - they were gzipped with the .gz extension and had some more changes detailed here. go-nexrad does not recognize these files, it gives an error when you give it the file after unzipping it. The one I am using to test is KABR20160531_000636_V06.gz. @bwiggs

@SteepAtticStairs SteepAtticStairs changed the title Possible web app, vector rendering, and velocity cleanup Possible web app, vector rendering, and different radar formats Jun 8, 2022
@bwiggs
Copy link
Owner

bwiggs commented Jun 9, 2022

I also wonder how different Level 3 files are from Level 2

It's different, I started on that a couple years ago and put it down. It's in a branch called nids in this repo. Data is available from GCP. See the README in the /nids dir for links.

all Level 2 files before June 1, 2016 had a different format

Interesting, I hadn't loaded up anything older than 2017. Created #12

@bwiggs
Copy link
Owner

bwiggs commented Jun 13, 2022

Fixed #12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants