Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ An extremely simple and ultra lightweight package for parsing through Hurdat2 da
# Usage
## Installation
This package can be installed using a simple `npm install` command
```
```bash
npm install hurdatparser
```
You can import it using `import`
```javascript
import { Hurdat, Util, Point } from "hurdatparser"
```
## [Documentation](https://github.com/wilburcoding/hurdatparser/tree/main/docs)

# Contributing
Expand Down
5 changes: 4 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
- [ ] Add support for multiple basins
- [x] Add support for multiple basins
- [ ] Add JTWC data support
- [ ] PAGASA data support
- [ ] Add SPC storm report data?
- [ ] Proofread docs and create examples
57 changes: 22 additions & 35 deletions docs/hurdat.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,28 @@ Initalize and load Hurdat2 data
const hurdat = new Hurdat("path/to/data.txt");
```

## `Hurdat.funcFilter(func)`

A method to filter storms using the passed function

#### Parameters

`func` - Function used to filter storms

#### Returns

Array of `Storm` filtered

#### Example Usage

Finds storms named "Henri"

```javascript
hurdat.funcFilter(function(storm) {
return storm.name == "Henri";
});
```

Find storms with forming in July

```javascript
hurdat.funcFilter(function(storm) {
return storm.formed.getMonth() == 6;
});
```

## `Hurdat.filter(query)`

A method to quickly query for storms

#### Parameters


`query` - An object containing different conditions to query for
`query` - An function with one parameter to filter items or an object containing different conditions to query for
#### Query object fields
**Note**: All `query` parameters are optional
- `season` (Number) - Look for storms in a certain year
- `namematch` (Regular expression) - Look for storms with names matching a certain regular expression
- `number` (Number or Array of numbers) - Look for storms whose number is equal to the provided number or is in the provided array
- `peakwind` (Number or Array of numbers) - Look for storms whose highest wind speed (kt) is equal to the provided number or is greater than or equal to the first item of the provided array (minimum) and less than or equal to the second item of the provided array (maximum)
- `peakpressure` (Number or Array of numbers) - Look for storms whose lowest pressure (mb) is equal to the provided number or is greater than or equal to the first item of the provided array (minimum) and less than or equal to the second item of the provided array (maximum)
- `peakwind` (Number or Array of 2 numbers) - Look for storms whose highest wind speed (kt) is equal to the provided number or is greater than or equal to the first item of the provided array (minimum) and less than or equal to the second item of the provided array (maximum)
- `peakpressure` (Number or Array of 2 numbers) - Look for storms whose lowest pressure (mb) is equal to the provided number or is greater than or equal to the first item of the provided array (minimum) and less than or equal to the second item of the provided array (maximum)
- `date` (Array of 2 Date objects) - Look for storms that were active during period of time in the provided array
- **Note**: This feature is currently experimental and could lead to inaccurate results
- `landfallnum` (Number or Array of numbers) - Look for storms whose number of landfalls is equal to the provided number or is greater than or equal to the first item of the provided array (beginning of date range) and less than or equal to the second item of the provided array (ending of date range)
- `landfallnum` (Number or Array of 2 numbers) - Look for storms whose number of landfalls is equal to the provided number or is greater than or equal to the first item of the provided array (beginning of date range) and less than or equal to the second item of the provided array (ending of date range)
- `point` (Array of 4 numbers) - Look for storms that have passed through an area (Item 1 of the provided array is the minimum latitude, Item 2 is the maximum latitude, Item 3 is the minimum longitude, Item 4 is the maximum longitude)
- `landfall` (Array of 4 numbers) - Look for storms that have made landfall in an area (Item 1 of the provided array is the minimum latitude, Item 2 is the maximum latitude, Item 3 is the minimum longitude, Item 4 is the maximum longitude)
- `distancekm` (Number or Array of 2 numbers) - Look for storms whose track distance in kilometers is equal to the provided number or is greater than or equal to the first item of the provided array (beginning of range) and less than or equal to the second item of the provided array (ending of range)
- `distancemi` (Number or Array of 2 numbers) - Look for storms whose track distance in miles is equal to the provided number or is greater than or equal to the first item of the provided array (beginning of range) and less than or equal to the second item of the provided array (ending of range)

#### Returns

Expand All @@ -87,11 +60,25 @@ hurdat.filter({"season" : "2005","landfallnum" : [3, 5]});
Find storms that made landfall on Long Island before 1950

```javascript
hurdat.filter({"date" : [new Date(1800, 1, 1), new Date(1950, 1, 1)], "landfall" : [40.54, 41.21, -71.75, -74.18]});
hurdat.filter({"date" : [new Date(1800, 0, 1), new Date(1950, 0, 1)], "landfall" : [40.54, 41.21, -71.75, -74.18]});
```

Find storms that made at least `5` landfalls and no more than `10` landfalls that had a peak intensity of `80` to `100` knots

```javascript
hurdat.filter({"peakwind": [80, 100], "landfallnum": [5, 10]})
```

Find storms that have a track distance of at least 2,500 miles and less than or equal to 10,000 miles after 2000

```javascript
hurdat.filter({"distancemi": [2500, 10000], "date": [new Date(2000, 0, 1), new Date(2500, 0, 1)]})
```

Example usage of using a function to filter storms with the name Henri

```javascript
hurdat.filter(function(storm) {
return storm.name == "HENRI";
})
```
31 changes: 31 additions & 0 deletions docs/point.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,34 @@ Get latitude value for Point
point.getLat();
```

## `Util.setLat(newlat)`

Set latitude value for Point

#### Parameters

`newlat` - new latitude value

#### Example Usage

Set latitude value for Point to 40

```javascript
point.setLat(40);
```

## `Util.setLong(newlong)`

Set longtiude value for Point

#### Parameters

`newlong` - new latitude value

#### Example Usage

Set longitude value for Point to 57

```javascript
point.setLong(57);
```
26 changes: 26 additions & 0 deletions docs/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,32 @@ Convert 50 kt to mph
util.ktToMph(50);
```

## `Util.coordDist(point1, point2, unit)`

Get distance between 2 coordinates

#### Parameters

`point1` - First point to calculate distance between
`point2` - Second point to calculate distance between
`unit` (Optional) - Specify unit for result. km" for kilometers and "mi" for miles. Default value is "km"

#### Returns

Distance between provided coordinates

#### Example usage

Calculate the distance between (59, 14) and (60, 14) in miles
```javascript
console.log(util.coordDist(new Point(59, 13), new Point(60, 14), "mi"))
```

Calculate the distance between (58, 5) and (59, 8) in kilometers
```javascript
console.log(util.coordDist(new Point(58, 5), new Point(59, 8)))
```

## `Util.ktToKph(kt)`

Convert knots to kph
Expand Down
Loading