adarvmap 0.1.41__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- adarvmap/__init__.py +61 -0
- adarvmap/cli.py +114 -0
- adarvmap/data/__init__.py +0 -0
- adarvmap/data/district_boundary_lite.fgb +0 -0
- adarvmap/data/state_boundary_lite.fgb +0 -0
- adarvmap/exceptions.py +10 -0
- adarvmap/interactive.py +567 -0
- adarvmap/layers.py +228 -0
- adarvmap/loader.py +256 -0
- adarvmap/map_builder.py +292 -0
- adarvmap/sidebar.py +457 -0
- adarvmap/spatial.py +159 -0
- adarvmap-0.1.41.dist-info/METADATA +249 -0
- adarvmap-0.1.41.dist-info/RECORD +18 -0
- adarvmap-0.1.41.dist-info/WHEEL +4 -0
- adarvmap-0.1.41.dist-info/entry_points.txt +2 -0
- adarvmap-0.1.41.dist-info/licenses/AUTHORS.md +14 -0
- adarvmap-0.1.41.dist-info/licenses/LICENSE +21 -0
adarvmap/__init__.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""adarvmap — Interactive epidemiological spot maps for India."""
|
|
2
|
+
|
|
3
|
+
from .exceptions import ColumnNotFoundError, NoCasePointsError, AdarvMapError
|
|
4
|
+
from .interactive import run_interactive, adarvmap_run
|
|
5
|
+
from .map_builder import AdarvMap
|
|
6
|
+
|
|
7
|
+
# Short, friendly alias so non-coders can simply do: import adarvmap; adarvmap.run()
|
|
8
|
+
run = adarvmap_run
|
|
9
|
+
|
|
10
|
+
__version__ = "0.1.41"
|
|
11
|
+
__all__ = [
|
|
12
|
+
"AdarvMap",
|
|
13
|
+
"run", # friendly alias for adarvmap_run
|
|
14
|
+
"adarvmap_run",
|
|
15
|
+
"run_interactive", # deprecated alias, kept for backward compat
|
|
16
|
+
"AdarvMapError",
|
|
17
|
+
"ColumnNotFoundError",
|
|
18
|
+
"NoCasePointsError",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
_BANNER = (
|
|
22
|
+
"\n"
|
|
23
|
+
"Interactive AdarvMap for India - created by ADARV\n"
|
|
24
|
+
"\n"
|
|
25
|
+
"No code required! To build your map, just run:\n"
|
|
26
|
+
"\n"
|
|
27
|
+
"adarvmap.run()\n"
|
|
28
|
+
"\n"
|
|
29
|
+
"You'll be asked to choose your data file, then your map appears.\n"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _in_interactive_session() -> bool:
|
|
34
|
+
"""True for a REPL, Jupyter/Colab notebook, or an interactive terminal."""
|
|
35
|
+
import sys
|
|
36
|
+
|
|
37
|
+
if "ipykernel" in sys.modules or "google.colab" in sys.modules:
|
|
38
|
+
return True
|
|
39
|
+
if hasattr(sys, "ps1"): # plain Python REPL
|
|
40
|
+
return True
|
|
41
|
+
try:
|
|
42
|
+
return bool(sys.stdout.isatty())
|
|
43
|
+
except Exception: # noqa: BLE001 — detached/!closed streams
|
|
44
|
+
return False
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _show_banner() -> None:
|
|
48
|
+
"""Show the first-run hint for non-coders.
|
|
49
|
+
|
|
50
|
+
Written to **stderr**, and only in an interactive session, so that
|
|
51
|
+
importing adarvmap never pollutes piped or redirected stdout (which
|
|
52
|
+
would corrupt scripts that emit CSV/JSON). This mirrors R's
|
|
53
|
+
``packageStartupMessage`` behaviour in the sibling adarvmapr package.
|
|
54
|
+
"""
|
|
55
|
+
import sys
|
|
56
|
+
|
|
57
|
+
if _in_interactive_session():
|
|
58
|
+
print(_BANNER, file=sys.stderr)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
_show_banner()
|
adarvmap/cli.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""Command-line interface for adarvmap."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
_EPILOG = """\
|
|
8
|
+
Examples:
|
|
9
|
+
adarvmap launch the guided wizard (easiest)
|
|
10
|
+
adarvmap data.csv build a map from data.csv
|
|
11
|
+
adarvmap data.csv -o my_map.html choose where to save the map
|
|
12
|
+
|
|
13
|
+
In Python or Google Colab:
|
|
14
|
+
from adarvmap import adarvmap_run
|
|
15
|
+
adarvmap_run()
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _build_parser() -> argparse.ArgumentParser:
|
|
20
|
+
p = argparse.ArgumentParser(
|
|
21
|
+
prog="adarvmap",
|
|
22
|
+
description="Generate an interactive epidemiological spot map for India.",
|
|
23
|
+
epilog=_EPILOG,
|
|
24
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
25
|
+
)
|
|
26
|
+
p.add_argument(
|
|
27
|
+
"csv",
|
|
28
|
+
nargs="?",
|
|
29
|
+
default=None,
|
|
30
|
+
help="Path to your data file (CSV/Excel). Omit it to launch the guided wizard.",
|
|
31
|
+
)
|
|
32
|
+
p.add_argument(
|
|
33
|
+
"-o", "--output",
|
|
34
|
+
default=None,
|
|
35
|
+
help="Output HTML file path (default: a dated file, e.g. adarvmap_200926.html).",
|
|
36
|
+
)
|
|
37
|
+
p.add_argument("--state-shp", default=None, help="Custom state boundary file.")
|
|
38
|
+
p.add_argument("--district-shp", default=None, help="Custom district boundary file.")
|
|
39
|
+
p.add_argument("--lat-col", default=None, help="Latitude column name.")
|
|
40
|
+
p.add_argument("--lon-col", default=None, help="Longitude column name.")
|
|
41
|
+
p.add_argument("--outcome-col", default=None, help="Outcome column name.")
|
|
42
|
+
p.add_argument("--case-value", default=None, help="Value that represents a case.")
|
|
43
|
+
p.add_argument(
|
|
44
|
+
"--count-cutoff",
|
|
45
|
+
type=int,
|
|
46
|
+
default=2,
|
|
47
|
+
help="District count threshold for mode selection (default: 2).",
|
|
48
|
+
)
|
|
49
|
+
p.add_argument(
|
|
50
|
+
"--cluster-color",
|
|
51
|
+
default="#E85252",
|
|
52
|
+
help="Hex colour for dot-density clusters (default: #E85252).",
|
|
53
|
+
)
|
|
54
|
+
p.add_argument(
|
|
55
|
+
"--case-color",
|
|
56
|
+
default="#D55757",
|
|
57
|
+
help="Hex colour for case pins (default: #D55757).",
|
|
58
|
+
)
|
|
59
|
+
p.add_argument(
|
|
60
|
+
"--control-color",
|
|
61
|
+
default="#7676E7",
|
|
62
|
+
help="Hex colour for control pins (default: #7676E7).",
|
|
63
|
+
)
|
|
64
|
+
p.add_argument(
|
|
65
|
+
"--case-label",
|
|
66
|
+
default=None,
|
|
67
|
+
help="Name for the case group on the map, e.g. Male (default: Case).",
|
|
68
|
+
)
|
|
69
|
+
p.add_argument(
|
|
70
|
+
"--control-label",
|
|
71
|
+
default=None,
|
|
72
|
+
help="Name for the control group on the map, e.g. Female (default: Control).",
|
|
73
|
+
)
|
|
74
|
+
return p
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def main(argv=None) -> None:
|
|
78
|
+
parser = _build_parser()
|
|
79
|
+
args = parser.parse_args(argv)
|
|
80
|
+
|
|
81
|
+
# No data file given → launch the friendly step-by-step wizard.
|
|
82
|
+
if args.csv is None:
|
|
83
|
+
from .interactive import adarvmap_run
|
|
84
|
+
adarvmap_run(args.output)
|
|
85
|
+
return
|
|
86
|
+
|
|
87
|
+
from .map_builder import AdarvMap
|
|
88
|
+
from .interactive import _default_output
|
|
89
|
+
|
|
90
|
+
output = args.output or _default_output()
|
|
91
|
+
try:
|
|
92
|
+
AdarvMap(
|
|
93
|
+
args.csv,
|
|
94
|
+
state_shp=args.state_shp,
|
|
95
|
+
district_shp=args.district_shp,
|
|
96
|
+
lat_col=args.lat_col,
|
|
97
|
+
long_col=args.lon_col,
|
|
98
|
+
outcome_col=args.outcome_col,
|
|
99
|
+
case_value=args.case_value,
|
|
100
|
+
count_cutoff=args.count_cutoff,
|
|
101
|
+
cluster_color=args.cluster_color,
|
|
102
|
+
case_color=args.case_color,
|
|
103
|
+
control_color=args.control_color,
|
|
104
|
+
case_label=args.case_label,
|
|
105
|
+
control_label=args.control_label,
|
|
106
|
+
).build().save(output)
|
|
107
|
+
print(f"Map saved to: {output}")
|
|
108
|
+
except Exception as exc:
|
|
109
|
+
print(f"Error: {exc}", file=sys.stderr)
|
|
110
|
+
sys.exit(1)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
if __name__ == "__main__":
|
|
114
|
+
main()
|
|
File without changes
|
|
Binary file
|
|
Binary file
|